my-homelab-configs/apps/opsproof/overlay/routes/web.go

42 lines
1.3 KiB
Go

package routes
import (
"net/http"
"go.laravel.com/auth"
"go.laravel.com/config"
"go.laravel.com/routing"
"go.laravel.com/web"
"app/handlers/authentication"
"app/handlers/demo"
"app/handlers/execution"
"app/handlers/incident"
"app/handlers/proposal"
"app/handlers/report"
"app/handlers/welcome"
appmiddleware "app/middleware"
)
func Web(route *routing.Router, cfg *config.Config) {
route.Get("/", welcome.Show)
route.Get("/demo", demo.Show)
route.Get("/login", authentication.Login).Name("login")
route.Get("/auth/dex", authentication.Start)
route.Get("/auth/dex/callback", authentication.Callback)
route.Post("/logout", authentication.Logout).Middleware(auth.Authenticate{}, appmiddleware.Operator{})
operator := route.Middleware(auth.Authenticate{}, appmiddleware.Operator{})
operator.Get("/incidents/{scope}/{target}", incident.Show)
operator.Post("/incidents/{scope}/{target}/proposals", proposal.Store)
operator.Get("/proposals/{proposal}", proposal.Show)
operator.Post("/proposals/{proposal}/approval", proposal.Approve)
operator.Post("/proposals/{proposal}/execution", proposal.Execute)
operator.Get("/executions/{execution}", execution.Show)
operator.Get("/reports/{report}", report.Show)
route.Fallback(func(*web.Request) *web.Response {
return web.Abort(http.StatusNotFound)
})
}