54 lines
1.2 KiB
Go
54 lines
1.2 KiB
Go
// Path: Backend/internal/httpx/api_routes.go
|
|
|
|
package httpx
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/go-chi/chi/v5"
|
|
)
|
|
|
|
type apiRoutes struct {
|
|
cfg RouterConfig
|
|
}
|
|
|
|
func newAPIRoutes(cfg RouterConfig) routeRegistrar {
|
|
return apiRoutes{cfg: cfg}
|
|
}
|
|
|
|
func (routes apiRoutes) Register(router chi.Router) {
|
|
router.Route("/v1", func(apiRouter chi.Router) {
|
|
apiRouter.Get("/", routes.handleIndex)
|
|
apiRouter.Get("/organizations", routes.handleOrganizations)
|
|
apiRouter.Get("/workspaces", routes.handleWorkspaces)
|
|
})
|
|
}
|
|
|
|
func (routes apiRoutes) handleIndex(w http.ResponseWriter, _ *http.Request) {
|
|
WriteJSON(w, http.StatusOK, map[string]any{
|
|
"service": routes.cfg.ServiceName,
|
|
"version": "v1",
|
|
"status": "scaffolded",
|
|
})
|
|
}
|
|
|
|
func (routes apiRoutes) handleOrganizations(w http.ResponseWriter, _ *http.Request) {
|
|
WriteJSON(w, http.StatusOK, map[string]any{
|
|
"data": []any{},
|
|
"meta": map[string]any{
|
|
"resource": "organizations",
|
|
"count": 0,
|
|
},
|
|
})
|
|
}
|
|
|
|
func (routes apiRoutes) handleWorkspaces(w http.ResponseWriter, _ *http.Request) {
|
|
WriteJSON(w, http.StatusOK, map[string]any{
|
|
"data": []any{},
|
|
"meta": map[string]any{
|
|
"resource": "workspaces",
|
|
"count": 0,
|
|
},
|
|
})
|
|
}
|