goweb-oidc/internal/route/mount.go

27 lines
638 B
Go
Raw Normal View History

2020-05-20 10:43:12 +02:00
package route
import (
oidc "forge.cadoles.com/wpetit/goweb-oidc"
"forge.cadoles.com/wpetit/goweb-oidc/internal/config"
2022-08-10 11:11:22 +02:00
chi "github.com/go-chi/chi/v5"
2020-05-20 10:43:12 +02:00
"gitlab.com/wpetit/goweb/static"
)
func Mount(r *chi.Mux, config *config.Config) error {
2020-05-20 13:06:04 +02:00
r.With(oidc.HandleCallback).Get("/oauth2/callback", handleLoginCallback)
r.Get("/", serveHomePage)
2020-05-20 10:43:12 +02:00
r.Get("/logout", handleLogout)
2020-05-20 13:06:04 +02:00
r.Get("/login", handleLogin)
r.Route("/profile", func(r chi.Router) {
r.Use(oidc.Middleware)
r.Get("/", serveProfilePage)
})
2020-05-20 10:43:12 +02:00
notFoundHandler := r.NotFoundHandler()
r.Get("/*", static.Dir(config.HTTP.PublicDir, "", notFoundHandler))
return nil
}