33 lines
1.3 KiB
Go
33 lines
1.3 KiB
Go
// Package api provides HTTP routing and handlers for the preferences-api service.
|
|
package api
|
|
|
|
import (
|
|
"git.threesix.ai/jordan/slack5-1770603014/pkg/app"
|
|
"git.threesix.ai/jordan/slack5-1770603014/services/preferences-api/internal/api/handlers"
|
|
"git.threesix.ai/jordan/slack5-1770603014/services/preferences-api/internal/service"
|
|
)
|
|
|
|
// RegisterRoutes registers all HTTP routes for the service.
|
|
// Routes are mounted under /api/preferences-api to match the ingress path routing.
|
|
func RegisterRoutes(application *app.App, preferencesService *service.PreferencesService) {
|
|
logger := application.Logger()
|
|
|
|
// Initialize handlers with injected services
|
|
healthHandler := handlers.NewHealth(logger)
|
|
preferencesHandler := handlers.NewPreferences(preferencesService, logger)
|
|
|
|
// Build and mount OpenAPI spec
|
|
spec := NewServiceSpec()
|
|
application.EnableDocs(spec)
|
|
|
|
// Register API routes under /api/{service-name} to match ingress path routing.
|
|
// The ingress routes /api/preferences-api/* to this service.
|
|
application.Route("/api/preferences-api", func(r app.Router) {
|
|
r.Get("/health", healthHandler.Check)
|
|
|
|
// Public routes (no auth required per spec)
|
|
r.Get("/preferences/{user_id}", app.Wrap(preferencesHandler.Get))
|
|
r.Put("/preferences/{user_id}", app.Wrap(preferencesHandler.Upsert))
|
|
})
|
|
}
|