52 lines
1.3 KiB
Go
52 lines
1.3 KiB
Go
// Path: Backend/internal/httpx/web_routes.go
|
|
|
|
package httpx
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
type webRoutes struct {
|
|
cfg RouterConfig
|
|
}
|
|
|
|
func newWebRoutes(cfg RouterConfig) routeRegistrar {
|
|
return webRoutes{cfg: cfg}
|
|
}
|
|
|
|
func (routes webRoutes) Register(router chi.Router) {
|
|
router.Get("/session", routes.handleSession)
|
|
router.Get("/bootstrap", routes.handleBootstrap)
|
|
router.Get("/me", routes.handleCurrentUser)
|
|
}
|
|
|
|
func (routes webRoutes) handleSession(w http.ResponseWriter, _ *http.Request) {
|
|
WriteJSON(w, http.StatusOK, map[string]any{
|
|
"service": routes.cfg.ServiceName,
|
|
"session": map[string]any{
|
|
"authenticated": false,
|
|
"mode": "cookie",
|
|
},
|
|
})
|
|
}
|
|
|
|
func (routes webRoutes) handleBootstrap(w http.ResponseWriter, _ *http.Request) {
|
|
WriteJSON(w, http.StatusOK, map[string]any{
|
|
"service": routes.cfg.ServiceName,
|
|
"app": map[string]any{
|
|
"name": routes.cfg.Config.AppName,
|
|
"environment": routes.cfg.Config.Environment,
|
|
},
|
|
"features": map[string]bool{
|
|
"auth": false,
|
|
"workspaces": false,
|
|
},
|
|
})
|
|
}
|
|
|
|
func (routes webRoutes) handleCurrentUser(w http.ResponseWriter, r *http.Request) {
|
|
WriteError(w, http.StatusNotImplemented, RequestIDFromContext(r.Context()), "not_implemented", "The current user endpoint is scaffolded but not implemented yet.")
|
|
}
|