27 lines
638 B
Go
27 lines
638 B
Go
package route
|
|
|
|
import (
|
|
oidc "forge.cadoles.com/wpetit/goweb-oidc"
|
|
"forge.cadoles.com/wpetit/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
|
|
}
|