Common HTTP routing infrastructure and standard endpoints.
This namespace provides the foundational routing structure for the application, including standard endpoints like health checks and API documentation, along with infrastructure for injecting module-specific routes.
Features:
Common HTTP routing infrastructure and standard endpoints. This namespace provides the foundational routing structure for the application, including standard endpoints like health checks and API documentation, along with infrastructure for injecting module-specific routes. Features: - Health check endpoints - OpenAPI/Swagger documentation routes - Module route injection system - Common route middleware configuration - Standardized route structure
(api-docs-routes config)Create OpenAPI/Swagger documentation routes with CSS fix for path rendering.
Args: config: Application configuration
Returns: Vector of API documentation route definitions
Create OpenAPI/Swagger documentation routes with CSS fix for path rendering. Args: config: Application configuration Returns: Vector of API documentation route definitions
(create-app config module-routes & options)Create a complete application with routes and handlers.
This is a convenience function that combines router creation and handler setup into a single step for simple applications.
Args: config: Application configuration module-routes: Vector of module-specific route definitions options: Same options as create-router plus handler options
Returns: Complete Ring application handler
Example: (def app (create-app config user-routes {:error-mappings user-errors :additional-health-checks health-fn}))
Create a complete application with routes and handlers.
This is a convenience function that combines router creation and handler
setup into a single step for simple applications.
Args:
config: Application configuration
module-routes: Vector of module-specific route definitions
options: Same options as create-router plus handler options
Returns:
Complete Ring application handler
Example:
(def app (create-app config user-routes
{:error-mappings user-errors
:additional-health-checks health-fn}))(create-handler router
&
{:keys [not-found-handler method-not-allowed-handler]
:or {not-found-handler (http-common/create-not-found-handler)
method-not-allowed-handler nil}})Create a complete Ring handler with routes and fallback handlers.
Serves static resources from /public directory BEFORE routing, bypassing content negotiation middleware that causes 406 errors.
Args: router: Reitit router instance options: Optional configuration map
Returns: Ring handler function
Example: (create-handler (create-router config module-routes))
Create a complete Ring handler with routes and fallback handlers. Serves static resources from /public directory BEFORE routing, bypassing content negotiation middleware that causes 406 errors. Args: router: Reitit router instance options: Optional configuration map Returns: Ring handler function Example: (create-handler (create-router config module-routes))
(create-router
config
module-routes
&
{:keys [additional-health-checks error-mappings extra-middleware]
:or {additional-health-checks nil error-mappings {} extra-middleware []}})Create a complete router with common routes and injected module routes.
Args: config: Application configuration module-routes: Vector of module-specific route definitions options: Optional configuration map with: - :additional-health-checks - Function for additional health checks - :error-mappings - Custom error type mappings - :middleware - Additional middleware to include
Returns: Reitit router with all routes configured
Example: (create-router config user-routes {:error-mappings {:user-not-found [404 "User Not Found"]} :additional-health-checks (fn [] {:database "connected"})})
Create a complete router with common routes and injected module routes.
Args:
config: Application configuration
module-routes: Vector of module-specific route definitions
options: Optional configuration map with:
- :additional-health-checks - Function for additional health checks
- :error-mappings - Custom error type mappings
- :middleware - Additional middleware to include
Returns:
Reitit router with all routes configured
Example:
(create-router config user-routes
{:error-mappings {:user-not-found [404 "User Not Found"]}
:additional-health-checks (fn [] {:database "connected"})})(health-routes config)(health-routes config additional-checks)Create standard health check routes.
Args: config: Application configuration additional-checks: Optional function for additional health checks
Returns: Vector of health check route definitions
Create standard health check routes. Args: config: Application configuration additional-checks: Optional function for additional health checks Returns: Vector of health check route definitions
(wrap-common-middleware handler)(wrap-common-middleware handler error-mappings)Wrap a handler with the standard common middleware stack.
This is useful when you need to apply the same middleware to custom handlers that aren't part of the main route structure.
Args: handler: Ring handler function error-mappings: Optional custom error mappings
Returns: Handler wrapped with common middleware
Wrap a handler with the standard common middleware stack. This is useful when you need to apply the same middleware to custom handlers that aren't part of the main route structure. Args: handler: Ring handler function error-mappings: Optional custom error mappings Returns: Handler wrapped with common middleware
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |