minimal

module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 29, 2022 License: MIT

README

Minimal

Minimal is a small, opinionated wrapper around Echo and Gorm.
Postgres set up and ready to go.

Absolute minimal configuration for a development environment

//go:embed assets
var embeddedFiles embed.FS

func embedFS(fs embed.FS) http.FileSystem {
	return http.FS(fs)
}

func main() {
	config := minimal.DevelopmentConfig
	_ = fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=5432 sslmode=disable TimeZone=Europe/Oslo",
		"localhost",
		"postgres",
		"postgres",
		"tmp",
	)
	config.DSN = dsn

	s := minimal.New(config, []minimal.Provider{
		&BaseRoutes{},
	}, []any{})

	s.Init(embedFS(embeddedFiles))
}

Routes defined like this:

type BaseRoutes struct{}

func (br *BaseRoutes) Register(e *echo.Echo) {
	e.GET("/", func(c echo.Context) error {
		return c.Render(200, "assets/index.html", nil)
	})
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL