pcmt/app/routes.go

42 lines
1.2 KiB
Go
Raw Normal View History

2023-03-22 23:03:21 +01:00
package app
import (
"net/http"
"git.dotya.ml/mirre-mt/pcmt/handlers"
2023-03-22 23:03:21 +01:00
"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))
2023-03-22 23:03:21 +01:00
// 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())
2023-03-22 23:03:21 +01:00
}