42 lines
1.0 KiB
Go
42 lines
1.0 KiB
Go
package app
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"git.dotya.ml/mirre-mt/pcmt/handlers"
|
|
"github.com/labstack/echo/v4"
|
|
"github.com/labstack/echo/v4/middleware"
|
|
)
|
|
|
|
func (a *App) SetupRoutes() {
|
|
e := a.E()
|
|
conf := a.Config()
|
|
liveMode := conf.LiveMode
|
|
assets := http.FileServer(a.getAssets(liveMode))
|
|
tmpls := a.getTemplates(liveMode)
|
|
|
|
// run this before declaring any handler funcs.
|
|
handlers.InitHandlers(a.version, conf, tmpls)
|
|
|
|
// keep /static/* as a compatibility fallback for /assets.
|
|
e.GET(
|
|
"/static/*",
|
|
nil,
|
|
middleware.Rewrite(
|
|
map[string]string{"/static/*": "/assets/$1"},
|
|
),
|
|
)
|
|
e.GET("/assets/*", echo.WrapHandler(http.StripPrefix("/assets/", assets)))
|
|
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())
|
|
}
|