goweb-oidc/internal/route/mount.go
2020-05-20 10:43:12 +02:00

26 lines
552 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.Group(func(r chi.Router) {
r.Use(oidc.Middleware)
r.Get("/", serveHomePage)
})
r.With(oidc.HandleCallback).Get("/oauth2/callback", handleLogin)
r.Get("/logout", handleLogout)
notFoundHandler := r.NotFoundHandler()
r.Get("/*", static.Dir(config.HTTP.PublicDir, "", notFoundHandler))
return nil
}