28 lines
632 B
Go
28 lines
632 B
Go
package route
|
|
|
|
import (
|
|
oidc "forge.cadoles.com/wpetit/goweb-oidc"
|
|
"forge.cadoles.com/wpetit/goweb-oidc/internal/config"
|
|
|
|
"github.com/go-chi/chi"
|
|
"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
|
|
}
|