pcmt/app/routes.go
leo f129606b8f
All checks were successful
continuous-integration/drone/push Build is passing
add bulk changes
* add handlers for signin,singup,logout...
* introduce ent ORM and add user schema
* add live mode, devel mode to selectively turn on features via
  config/flags
* add templates, handle embedding moar smarter:
  * live mode uses live folder structure, else embedded templates are
    used
* start using tailwindcss to style stuff
* add development goodies for hot-reloading (browser-sync - bs.js)
* pimp-up config.dhall with actual custom config Type (enables remote
  schema and local values only as needed)
* add justfile (alternative to makefile for process automation)
2023-04-13 00:07:08 +02:00

42 lines
1.2 KiB
Go

package app
import (
"net/http"
"git.dotya.ml/mirre-mt/pcmt/handlers"
"github.com/labstack/echo/v4"
)
func (a *App) SetupRoutes() {
e := a.E()
conf := a.Config()
liveMode := conf.LiveMode
// liveMode := a.Config().LiveMode
assets := http.FileServer(a.getAssets(liveMode))
tmpls := a.getTemplates(liveMode)
// tmplHandler := http.FileServer(a.getTemplates(live))
// run this before declaring any handler funcs.
// handlers.SetConfig(conf)
// handlers.SetAppVer(a.version)
// handlers.InitTemplates(tmpls)
handlers.InitHandlers(a.version, conf, tmpls)
// e.GET("/", echo.WrapHandler(assetHandler))
e.GET("/static/*", echo.WrapHandler(http.StripPrefix("/static/", assets)))
// e.GET("/", handlers.Index(indexTmpl))
// e.GET("/", handlers.Index(conf, tmpls))
// e.GET("/", handlers.Index(conf))
e.GET("/", handlers.Index())
e.GET("/signin", handlers.Signin())
e.POST("/signin", handlers.SigninPost(a.db))
e.GET("/signup", handlers.Signup())
e.POST("/signup", handlers.SignupPost(a.db))
e.GET("/home", handlers.Home())
e.GET("/logout", handlers.Logout())
e.POST("/logout", handlers.Logout())
// administrative endpoints.
e.GET("/admin/*", handlers.Admin())
}