Add initial Go server skeleton with HTTP handlers, middleware, job runner, and stubs
This commit is contained in:
24
internal/http/router.go
Normal file
24
internal/http/router.go
Normal file
@@ -0,0 +1,24 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user