add middlewares, handlers and database models
This commit is contained in:
parent
979a415b95
commit
7e288ea67a
24 changed files with 1045 additions and 14 deletions
|
|
@ -12,9 +12,14 @@ import (
|
|||
|
||||
func SetupRoutes(a *app.App) http.Handler {
|
||||
auth := handler.NewAuthHandler()
|
||||
home := handler.NewHomeHandler()
|
||||
|
||||
mux := http.NewServeMux()
|
||||
|
||||
// ====================================================================================
|
||||
// PUBLIC ROUTES
|
||||
// ====================================================================================
|
||||
|
||||
// Static
|
||||
sub, _ := fs.Sub(assets.AssetsFS, ".")
|
||||
mux.Handle("GET /assets/", http.StripPrefix("/assets/", http.FileServer(http.FS(sub))))
|
||||
|
|
@ -22,5 +27,17 @@ func SetupRoutes(a *app.App) http.Handler {
|
|||
// Auth pages
|
||||
mux.HandleFunc("GET /auth", middleware.RequireGuest(auth.AuthPage))
|
||||
|
||||
return mux
|
||||
// 404
|
||||
mux.HandleFunc("/{path...}", home.NotFoundPage)
|
||||
|
||||
// Global middlewares
|
||||
handler := middleware.Chain(
|
||||
mux,
|
||||
middleware.Config(a.Cfg),
|
||||
middleware.RequestLogging,
|
||||
middleware.CSRFProtection,
|
||||
middleware.WithURLPath,
|
||||
)
|
||||
|
||||
return handler
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue