Feat: Backend scaffolding and local dev stack
This commit is contained in:
53
Backend/internal/httpx/api_routes.go
Normal file
53
Backend/internal/httpx/api_routes.go
Normal file
@@ -0,0 +1,53 @@
|
||||
// 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,
|
||||
},
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user