goweb-oidc/internal/route/mount.go

27 lines
640 B
Go

package route
import (
oidc "forge.cadoles.com/cadoles/goweb-oidc"
"forge.cadoles.com/cadoles/goweb-oidc/internal/config"
chi "github.com/go-chi/chi/v5"
"gitlab.com/wpetit/goweb/static"
)
func Mount(r *chi.Mux, config *config.Config) error {
r.With(oidc.HandleCallback).Get("/oauth2/callback", handleLoginCallback)
r.Get("/", serveHomePage)
r.Get("/logout", handleLogout)
r.Get("/login", handleLogin)
r.Route("/profile", func(r chi.Router) {
r.Use(oidc.Middleware)
r.Get("/", serveProfilePage)
})
notFoundHandler := r.NotFoundHandler()
r.Get("/*", static.Dir(config.HTTP.PublicDir, "", notFoundHandler))
return nil
}