Files
storage-appliance/internal/http/router.go

25 lines
666 B
Go

package http
import (
"net/http"
"github.com/go-chi/chi/v5"
)
// RegisterRoutes registers HTTP routes onto the router
func RegisterRoutes(r *chi.Mux, app *App) {
r.Use(Logging)
r.Use(RequestID)
r.Use(Auth)
r.Get("/", app.DashboardHandler)
r.Get("/dashboard", app.DashboardHandler)
r.Get("/healthz", func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) })
// API namespace
r.Route("/api", func(r chi.Router) {
r.Get("/pools", app.PoolsHandler)
r.With(RBAC("storage.pool.create")).Post("/pools", app.CreatePoolHandler) // create a pool -> creates a job
r.Get("/jobs", app.JobsHandler)
})
r.Get("/static/*", StaticHandler)
}