pub fn routes(app_state: AppState) -> Router<AppState>
Expand description
Builds the complete application router for all HTTP endpoints.
The returned router has AppState
as its state type and mounts
all core API routes under their respective base paths.
§Route Structure:
/health
→ Health check endpoint (no authentication required)./auth
→ Authentication endpoints (login, refresh, etc.)./users
→ User management (restricted to admins viarequire_admin
middleware)./users/{user_id}/avatar
→ Publicly accessible avatar retrieval./modules
→ Module CRUD, personnel management, and assignments (requires authentication)./me
→ User-specific endpoints (announcements, tickets, assignments, etc.)/test
→ Development/test-only routes (mounted only ifenv != production
).
The /test
route group is mounted here instead of in main
to:
- Keep
main
focused on server startup logic only. - Avoid changing the
Router
type after construction, which can cause trait bound issues. - Ensure that all route registration logic is centralized in one place.