-
Notifications
You must be signed in to change notification settings - Fork 0
/
web.go
34 lines (26 loc) · 882 Bytes
/
web.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package route
import (
"github.com/labstack/echo/v4"
"github.com/labstack/echo/v4/middleware"
"github.com/sparkymat/honey/auth"
"github.com/sparkymat/honey/internal/handler"
)
func registerWebRoutes(app *echo.Group, cfg ConfigService, db DatabaseService) {
webApp := app.Group("")
webApp.Use(middleware.CSRFWithConfig(middleware.CSRFConfig{
TokenLookup: "form:csrf",
}))
webApp.GET("/login", handler.Login(cfg, db))
webApp.POST("/login", handler.DoLogin(cfg, db))
if !cfg.DisableRegistration() {
webApp.GET("/register", handler.Register(cfg, db))
webApp.POST("/register", handler.DoRegister(cfg, db))
}
authenticatedWebApp := webApp.Group("")
if cfg.ReverseProxyAuthentication() {
authenticatedWebApp.Use(auth.ProxyAuthMiddleware(cfg, db))
} else {
authenticatedWebApp.Use(auth.Middleware(cfg, db))
}
authenticatedWebApp.GET("/", handler.Home())
}