|
Csilk 0.2.1
A lightweight, high-performance C HTTP web framework
|
#include "csilk/csilk.h"

Go to the source code of this file.
Macros | |
| #define | csilk_app_get(app, path, handler) csilk_app_add_route(app, "GET", path, handler) |
| Convenience macro to register a GET route via the app API. | |
| #define | csilk_app_get_ext(app, path, handler, in, out, summary, desc) csilk_app_add_route_extended(app, "GET", path, handler, in, out, summary, desc) |
| Convenience macro to register a GET route with OpenAPI metadata. | |
| #define | csilk_app_get_perm(app, path, handler, perm, res) csilk_app_add_route_perm(app, "GET", path, handler, perm, res) |
| Convenience macro to register a GET route with permission. | |
| #define | csilk_app_post(app, path, handler) csilk_app_add_route(app, "POST", path, handler) |
| Convenience macro to register a POST route via the app API. | |
| #define | csilk_app_post_ext(app, path, handler, in, out, summary, desc) csilk_app_add_route_extended(app, "POST", path, handler, in, out, summary, desc) |
| Convenience macro to register a POST route with OpenAPI metadata. | |
| #define | csilk_app_post_perm(app, path, handler, perm, res) csilk_app_add_route_perm(app, "POST", path, handler, perm, res) |
| Convenience macro to register a POST route with permission. | |
| #define | csilk_app_put(app, path, handler) csilk_app_add_route(app, "PUT", path, handler) |
| Convenience macro to register a PUT route via the app API. | |
| #define | csilk_app_put_ext(app, path, handler, in, out, summary, desc) csilk_app_add_route_extended(app, "PUT", path, handler, in, out, summary, desc) |
| Convenience macro to register a PUT route with OpenAPI metadata. | |
| #define | csilk_app_put_perm(app, path, handler, perm, res) csilk_app_add_route_perm(app, "PUT", path, handler, perm, res) |
| Convenience macro to register a PUT route with permission. | |
| #define | csilk_app_delete(app, path, handler) csilk_app_add_route(app, "DELETE", path, handler) |
| Convenience macro to register a DELETE route via the app API. | |
| #define | csilk_app_delete_ext(app, path, handler, in, out, summary, desc) csilk_app_add_route_extended(app, "DELETE", path, handler, in, out, summary, desc) |
| Convenience macro to register a DELETE route with OpenAPI metadata. | |
| #define | csilk_app_delete_perm(app, path, handler, perm, res) csilk_app_add_route_perm(app, "DELETE", path, handler, perm, res) |
| Convenience macro to register a DELETE route with permission. | |
| #define | csilk_app_patch(app, path, handler) csilk_app_add_route(app, "PATCH", path, handler) |
| Convenience macro to register a PATCH route via the app API. | |
| #define | csilk_app_patch_ext(app, path, handler, in, out, summary, desc) csilk_app_add_route_extended(app, "PATCH", path, handler, in, out, summary, desc) |
| Convenience macro to register a PATCH route with OpenAPI metadata. | |
| #define | csilk_app_patch_perm(app, path, handler, perm, res) csilk_app_add_route_perm(app, "PATCH", path, handler, perm, res) |
| Convenience macro to register a PATCH route with permission. | |
| #define | csilk_app_options(app, path, handler) csilk_app_add_route(app, "OPTIONS", path, handler) |
| Convenience macro to register an OPTIONS route via the app API. | |
| #define | csilk_app_options_ext(app, path, handler, in, out, summary, desc) csilk_app_add_route_extended(app, "OPTIONS", path, handler, in, out, summary, desc) |
| Convenience macro to register an OPTIONS route with OpenAPI metadata. | |
| #define | csilk_app_options_perm(app, path, handler, perm, res) csilk_app_add_route_perm(app, "OPTIONS", path, handler, perm, res) |
| Convenience macro to register an OPTIONS route with permission. | |
| #define | csilk_app_head(app, path, handler) csilk_app_add_route(app, "HEAD", path, handler) |
| Convenience macro to register a HEAD route via the app API. | |
| #define | csilk_app_head_ext(app, path, handler, in, out, summary, desc) csilk_app_add_route_extended(app, "HEAD", path, handler, in, out, summary, desc) |
| Convenience macro to register a HEAD route with OpenAPI metadata. | |
| #define | csilk_app_head_perm(app, path, handler, perm, res) csilk_app_add_route_perm(app, "HEAD", path, handler, perm, res) |
| Convenience macro to register a HEAD route with permission. | |
Functions | |
| csilk_app_t * | csilk_app_new (const char *config_path) |
| Create a new application with optional YAML config. | |
| void | csilk_app_free (csilk_app_t *app) |
| Deallocate all application resources. | |
| void | csilk_app_log_level (csilk_app_t *app, csilk_log_level_t level) |
| Set the minimum log level. | |
| void | csilk_app_log_file (csilk_app_t *app, const char *path, size_t max_sz) |
| Enable file logging with optional rotation. | |
| void | csilk_app_log_json (csilk_app_t *app, int enable) |
| Enable or disable JSON structured log output. | |
| void | csilk_app_use (csilk_app_t *app, csilk_handler_t h) |
| Register a global middleware that runs on every route. | |
| void | csilk_app_use_group (csilk_app_t *app, const char *prefix, csilk_handler_t h) |
| Register a middleware that runs only on a specific prefix group. | |
| void | csilk_app_apply_config (csilk_app_t *app) |
| Auto-apply built-in middleware based on current config. | |
| void | csilk_app_add_route (csilk_app_t *app, const char *method, const char *path, csilk_handler_t handler) |
| Register a route with a single handler. | |
| void | csilk_app_add_handlers (csilk_app_t *app, const char *method, const char *path, csilk_handler_t *handlers, size_t n) |
| Register a route with multiple handlers (middleware + handler). | |
| void | csilk_app_add_route_extended (csilk_app_t *app, const char *method, const char *path, csilk_handler_t handler, const char *input_type, const char *output_type, const char *summary, const char *description) |
| Register a route with OpenAPI metadata (input/output types). | |
| void | csilk_app_add_route_perm (csilk_app_t *app, const char *method, const char *path, csilk_handler_t handler, const char *perm_required, const char *perm_resource) |
| Register a route with permission metadata. | |
| void | csilk_app_add_route_extended_perm (csilk_app_t *app, const char *method, const char *path, csilk_handler_t handler, const char *input_type, const char *output_type, const char *summary, const char *description, const char *perm_required, const char *perm_resource) |
| Register a route with full metadata including permissions. | |
| void | csilk_app_static (csilk_app_t *app, const char *prefix, const char *root_dir) |
| Serve static files from a local directory. | |
| void | csilk_app_set_server_config (csilk_app_t *app, csilk_server_config_t c) |
| Apply server-level configuration (timeouts, limits, TCP options). | |
| csilk_config_t * | csilk_app_config (csilk_app_t *app) |
| Get a copy of the current application configuration. | |
| void | csilk_app_enable_openapi (csilk_app_t *app, int enable) |
| Enable or disable the built-in /openapi.json endpoint. The endpoint is enabled by default when the app is created. | |
| int | csilk_app_run (csilk_app_t *app, int port) |
| Start the server and block until stopped (Ctrl+C). | |
| csilk_router_t * | csilk_app_router (csilk_app_t *app) |
| Get the underlying router for advanced operations. | |
| csilk_server_t * | csilk_app_server (csilk_app_t *app) |
| Get the underlying server for advanced operations. | |
| #define csilk_app_delete | ( | app, | |
| path, | |||
| handler | |||
| ) | csilk_app_add_route(app, "DELETE", path, handler) |
Convenience macro to register a DELETE route via the app API.
| app | Application handle. |
| path | URL path pattern. |
| handler | Handler function. |
| #define csilk_app_delete_ext | ( | app, | |
| path, | |||
| handler, | |||
| in, | |||
| out, | |||
| summary, | |||
| desc | |||
| ) | csilk_app_add_route_extended(app, "DELETE", path, handler, in, out, summary, desc) |
Convenience macro to register a DELETE route with OpenAPI metadata.
| #define csilk_app_delete_perm | ( | app, | |
| path, | |||
| handler, | |||
| perm, | |||
| res | |||
| ) | csilk_app_add_route_perm(app, "DELETE", path, handler, perm, res) |
Convenience macro to register a DELETE route with permission.
| #define csilk_app_get | ( | app, | |
| path, | |||
| handler | |||
| ) | csilk_app_add_route(app, "GET", path, handler) |
Convenience macro to register a GET route via the app API.
| app | Application handle. |
| path | URL path pattern. |
| handler | Handler function. |
| #define csilk_app_get_ext | ( | app, | |
| path, | |||
| handler, | |||
| in, | |||
| out, | |||
| summary, | |||
| desc | |||
| ) | csilk_app_add_route_extended(app, "GET", path, handler, in, out, summary, desc) |
Convenience macro to register a GET route with OpenAPI metadata.
| #define csilk_app_get_perm | ( | app, | |
| path, | |||
| handler, | |||
| perm, | |||
| res | |||
| ) | csilk_app_add_route_perm(app, "GET", path, handler, perm, res) |
Convenience macro to register a GET route with permission.
| #define csilk_app_head | ( | app, | |
| path, | |||
| handler | |||
| ) | csilk_app_add_route(app, "HEAD", path, handler) |
Convenience macro to register a HEAD route via the app API.
| app | Application handle. |
| path | URL path pattern. |
| handler | Handler function. |
| #define csilk_app_head_ext | ( | app, | |
| path, | |||
| handler, | |||
| in, | |||
| out, | |||
| summary, | |||
| desc | |||
| ) | csilk_app_add_route_extended(app, "HEAD", path, handler, in, out, summary, desc) |
Convenience macro to register a HEAD route with OpenAPI metadata.
| #define csilk_app_head_perm | ( | app, | |
| path, | |||
| handler, | |||
| perm, | |||
| res | |||
| ) | csilk_app_add_route_perm(app, "HEAD", path, handler, perm, res) |
Convenience macro to register a HEAD route with permission.
| #define csilk_app_options | ( | app, | |
| path, | |||
| handler | |||
| ) | csilk_app_add_route(app, "OPTIONS", path, handler) |
Convenience macro to register an OPTIONS route via the app API.
| app | Application handle. |
| path | URL path pattern. |
| handler | Handler function. |
| #define csilk_app_options_ext | ( | app, | |
| path, | |||
| handler, | |||
| in, | |||
| out, | |||
| summary, | |||
| desc | |||
| ) | csilk_app_add_route_extended(app, "OPTIONS", path, handler, in, out, summary, desc) |
Convenience macro to register an OPTIONS route with OpenAPI metadata.
| #define csilk_app_options_perm | ( | app, | |
| path, | |||
| handler, | |||
| perm, | |||
| res | |||
| ) | csilk_app_add_route_perm(app, "OPTIONS", path, handler, perm, res) |
Convenience macro to register an OPTIONS route with permission.
| #define csilk_app_patch | ( | app, | |
| path, | |||
| handler | |||
| ) | csilk_app_add_route(app, "PATCH", path, handler) |
Convenience macro to register a PATCH route via the app API.
| app | Application handle. |
| path | URL path pattern. |
| handler | Handler function. |
| #define csilk_app_patch_ext | ( | app, | |
| path, | |||
| handler, | |||
| in, | |||
| out, | |||
| summary, | |||
| desc | |||
| ) | csilk_app_add_route_extended(app, "PATCH", path, handler, in, out, summary, desc) |
Convenience macro to register a PATCH route with OpenAPI metadata.
| #define csilk_app_patch_perm | ( | app, | |
| path, | |||
| handler, | |||
| perm, | |||
| res | |||
| ) | csilk_app_add_route_perm(app, "PATCH", path, handler, perm, res) |
Convenience macro to register a PATCH route with permission.
| #define csilk_app_post | ( | app, | |
| path, | |||
| handler | |||
| ) | csilk_app_add_route(app, "POST", path, handler) |
Convenience macro to register a POST route via the app API.
| app | Application handle. |
| path | URL path pattern. |
| handler | Handler function. |
| #define csilk_app_post_ext | ( | app, | |
| path, | |||
| handler, | |||
| in, | |||
| out, | |||
| summary, | |||
| desc | |||
| ) | csilk_app_add_route_extended(app, "POST", path, handler, in, out, summary, desc) |
Convenience macro to register a POST route with OpenAPI metadata.
| #define csilk_app_post_perm | ( | app, | |
| path, | |||
| handler, | |||
| perm, | |||
| res | |||
| ) | csilk_app_add_route_perm(app, "POST", path, handler, perm, res) |
Convenience macro to register a POST route with permission.
| #define csilk_app_put | ( | app, | |
| path, | |||
| handler | |||
| ) | csilk_app_add_route(app, "PUT", path, handler) |
Convenience macro to register a PUT route via the app API.
| app | Application handle. |
| path | URL path pattern. |
| handler | Handler function. |
| #define csilk_app_put_ext | ( | app, | |
| path, | |||
| handler, | |||
| in, | |||
| out, | |||
| summary, | |||
| desc | |||
| ) | csilk_app_add_route_extended(app, "PUT", path, handler, in, out, summary, desc) |
Convenience macro to register a PUT route with OpenAPI metadata.
| #define csilk_app_put_perm | ( | app, | |
| path, | |||
| handler, | |||
| perm, | |||
| res | |||
| ) | csilk_app_add_route_perm(app, "PUT", path, handler, perm, res) |
Convenience macro to register a PUT route with permission.
| void csilk_app_add_handlers | ( | csilk_app_t * | app, |
| const char * | method, | ||
| const char * | path, | ||
| csilk_handler_t * | handlers, | ||
| size_t | n | ||
| ) |
Register a route with multiple handlers (middleware + handler).
| app | Application handle. |
| method | HTTP method string. |
| path | URL pattern. |
| handlers | Array of handler functions. |
| n | Number of handlers. |
Register a route with multiple handlers (middleware + handler).
| app | Application instance. |
| method | HTTP method. |
| path | URL path. |
| handlers | Array of handler functions. |
| n | Number of handlers in the array. |
| void csilk_app_add_route | ( | csilk_app_t * | app, |
| const char * | method, | ||
| const char * | path, | ||
| csilk_handler_t | handler | ||
| ) |
Register a route with a single handler.
| app | Application handle. |
| method | HTTP method string (e.g., "GET"). |
| path | URL pattern (supports :param and *wildcard). |
| handler | Route handler function. |
Register a route with a single handler.
| app | Application instance. |
| method | HTTP method (e.g., "GET", "POST"). |
| path | URL path (e.g., "/users"). |
| handler | Handler function. |
| void csilk_app_add_route_extended | ( | csilk_app_t * | app, |
| const char * | method, | ||
| const char * | path, | ||
| csilk_handler_t | handler, | ||
| const char * | input_type, | ||
| const char * | output_type, | ||
| const char * | summary, | ||
| const char * | description | ||
| ) |
Register a route with OpenAPI metadata (input/output types).
| app | Application handle. |
| method | HTTP method string. |
| path | URL pattern (supports :param and *wildcard). |
| handler | Route handler function. |
| input_type | Registered type name for request body (NULL if none). |
| output_type | Registered type name for response (NULL if none). |
| summary | Short operation summary (NULL if none). |
| description | Detailed operation description (NULL if none). |
Register a route with OpenAPI metadata (input/output types).
| app | Application instance. |
| method | HTTP method. |
| path | URL path. |
| handler | Handler function. |
| input_type | Registered type name for request body JSON schema. |
| output_type | Registered type name for response body JSON schema. |
| summary | Short description for the OpenAPI operation. |
| description | Detailed description for the OpenAPI operation. |
| void csilk_app_add_route_extended_perm | ( | csilk_app_t * | app, |
| const char * | method, | ||
| const char * | path, | ||
| csilk_handler_t | handler, | ||
| const char * | input_type, | ||
| const char * | output_type, | ||
| const char * | summary, | ||
| const char * | description, | ||
| const char * | perm_required, | ||
| const char * | perm_resource | ||
| ) |
Register a route with full metadata including permissions.
| app | Application handle. |
| method | HTTP method string. |
| path | URL pattern. |
| handler | Route handler function. |
| input_type | Registered type name for request body (NULL if none). |
| output_type | Registered type name for response (NULL if none). |
| summary | Short operation summary (NULL if none). |
| description | Detailed operation description (NULL if none). |
| perm_required | Permission identifier (e.g., "read"), or NULL. |
| perm_resource | Resource pattern (e.g., "users:*"), or NULL. |
Register a route with full metadata including permissions.
| app | Application handle. |
| method | HTTP method string. |
| path | URL pattern (supports :param and *wildcard). |
| handler | Route handler function. |
| input_type | Registered type name for request body (NULL if none). |
| output_type | Registered type name for response (NULL if none). |
| summary | Short operation summary (NULL if none). |
| description | Detailed operation description (NULL if none). |
Register a route with OpenAPI metadata (input/output types).
| app | Application instance. |
| method | HTTP method. |
| path | URL path. |
| handler | Handler function. |
| input_type | Registered type name for request body JSON schema. |
| output_type | Registered type name for response body JSON schema. |
| summary | Short description for the OpenAPI operation. |
| description | Detailed description for the OpenAPI operation. |
| perm_required | Permission required for this route, or NULL. |
| perm_resource | Resource pattern for permission check, or NULL. |
| void csilk_app_add_route_perm | ( | csilk_app_t * | app, |
| const char * | method, | ||
| const char * | path, | ||
| csilk_handler_t | handler, | ||
| const char * | perm_required, | ||
| const char * | perm_resource | ||
| ) |
Register a route with permission metadata.
| app | Application handle. |
| method | HTTP method string. |
| path | URL pattern (supports :param and *wildcard). |
| handler | Route handler function. |
| perm_required | Permission identifier (e.g., "read"), or NULL. |
| perm_resource | Resource pattern (e.g., "users:*"), or NULL. |
| app | Application instance. |
| method | HTTP method. |
| path | URL path. |
| handler | Handler function. |
| perm_required | Permission identifier (e.g., "read"), or NULL. |
| perm_resource | Resource pattern (e.g., "users:*"), or NULL. |
| void csilk_app_apply_config | ( | csilk_app_t * | app | ) |
Auto-apply built-in middleware based on current config.
Reads the loaded YAML configuration and installs the following middleware when the corresponding config flags are enabled: logger, recovery, CORS, CSRF, rate-limit, auth, gzip. Safe to call even without a loaded config — disabled options are no-ops.
| app | Application handle. |
Auto-apply built-in middleware based on current config.
Reads the current app config and sets up static file serving if config.static_files.enable is true and root_dir is configured. The prefix defaults to "/static" if not specified in the config.
| app | Application instance. |
| csilk_config_t * csilk_app_config | ( | csilk_app_t * | app | ) |
Get a copy of the current application configuration.
| app | Application handle. |
Get a copy of the current application configuration.
| app | Application instance. |
| void csilk_app_enable_openapi | ( | csilk_app_t * | app, |
| int | enable | ||
| ) |
Enable or disable the built-in /openapi.json endpoint. The endpoint is enabled by default when the app is created.
| app | Application handle. |
| enable | 1 to enable, 0 to disable (handler returns 404). |
Enable or disable the built-in /openapi.json endpoint. The endpoint is enabled by default when the app is created.
When enabled, the router's routes are exposed as an OpenAPI 3.0 specification at /openapi.json. When disabled, the endpoint returns 404.
| app | Application instance. |
| enable | 1 to enable, 0 to disable. |
| void csilk_app_free | ( | csilk_app_t * | app | ) |
Deallocate all application resources.
Stops the server (if running), frees the router, config, and any registered middleware. Safe to call with a NULL app.
| app | Application handle (may be NULL). |
Deallocate all application resources.
Server must be freed before the router because the server holds a reference to the router internally.
| app | The application instance to free (may be NULL). |
| void csilk_app_log_file | ( | csilk_app_t * | app, |
| const char * | path, | ||
| size_t | max_sz | ||
| ) |
Enable file logging with optional rotation.
| app | Application handle. |
| path | Log file path. |
| max_sz | Max file size before rotation (0 to disable). |
Enable file logging with optional rotation.
Sets the log output to the specified file path. If max_sz > 0, the log file is rotated (renamed to .1) when it exceeds this size.
| app | Application instance. |
| path | File path for log output. Pass NULL to disable file logging and revert to stdout. |
| max_sz | Maximum file size in bytes before rotation (0 = no limit). |
| void csilk_app_log_json | ( | csilk_app_t * | app, |
| int | enable | ||
| ) |
Enable or disable JSON structured log output.
| app | Application handle. |
| enable | 1 to enable JSON format, 0 for plain text. |
Enable or disable JSON structured log output.
When enabled, log entries are emitted as JSON objects with structured fields (timestamp, level, file, line, message, request_id). When disabled, plain text format is used.
| app | Application instance. |
| enable | 1 for JSON format, 0 for plain text. |
| void csilk_app_log_level | ( | csilk_app_t * | app, |
| csilk_log_level_t | level | ||
| ) |
Set the minimum log level.
| app | Application handle. |
| level | Minimum log level. |
Set the minimum log level.
Reinitializes the logger with the updated level. Messages below this level are filtered out.
| app | Application instance. |
| level | New minimum log level (e.g., CSILK_LOG_DEBUG). |
| csilk_app_t * csilk_app_new | ( | const char * | config_path | ) |
Create a new application with optional YAML config.
Initialises the router, server, logger, database subsystem, and AI subsystem. If config_path is provided and readable, settings for CORS, rate-limiting, static files, auth, AI, and cipher are loaded. If config_path is NULL or the file doesn't exist, sensible defaults are used (port 8080, stderr logging, all middleware disabled).
| config_path | Path to YAML config file, or NULL for defaults. |
Create a new application with optional YAML config.
Phase 1 — Config & Logging
Phase 2 — Core objects
Phase 3 — Built-in endpoints
Register /csdk-docs/ as a static file route pointing to the bundled Swagger UI assets.
| config_path | Path to a YAML configuration file, or NULL to use defaults (port 8080, info-level logging to stdout). |
| csilk_router_t * csilk_app_router | ( | csilk_app_t * | app | ) |
Get the underlying router for advanced operations.
| app | Application handle. |
Get the underlying router for advanced operations.
| app | Application instance. |
| int csilk_app_run | ( | csilk_app_t * | app, |
| int | port | ||
| ) |
Start the server and block until stopped (Ctrl+C).
| app | Application handle. |
| port | TCP port to listen on. |
Start the server and block until stopped (Ctrl+C).
This is the main entry point into the event-driven I/O loop. It delegates to csilk_server_run() which:
| app | Application instance. |
| port | TCP port to listen on. Pass 0 or negative to use the port from the application config (default 8080). |
| csilk_server_t * csilk_app_server | ( | csilk_app_t * | app | ) |
Get the underlying server for advanced operations.
| app | Application handle. |
Get the underlying server for advanced operations.
| app | Application instance. |
| void csilk_app_set_server_config | ( | csilk_app_t * | app, |
| csilk_server_config_t | c | ||
| ) |
Apply server-level configuration (timeouts, limits, TCP options).
| app | Application handle. |
| c | Server configuration struct. |
Apply server-level configuration (timeouts, limits, TCP options).
Updates both the app's stored config and applies it to the server instance. This overrides any previous server config.
| app | Application instance. |
| c | Server configuration struct. |
| void csilk_app_static | ( | csilk_app_t * | app, |
| const char * | prefix, | ||
| const char * | root_dir | ||
| ) |
Serve static files from a local directory.
| app | Application handle. |
| prefix | URL path prefix (e.g., "/static"). |
| root_dir | Local directory to serve files from. |
Serve static files from a local directory.
prefix:WILDCARD path — wildcard route that captures everything after the prefix./ — the prefix root (redirects to the index file). Both routes use the same internal static_serve handler, which scans g_static[] at request time to find the correct root_dir.The dual-route pattern means both /static/ and /static/foo/bar.jpg work. The static_prefix context variable lets csilk_static() strip the URL prefix from the filesystem path.
| app | Application instance. |
| prefix | URL path prefix for static files (e.g., "/static"). |
| root_dir | Local filesystem directory to serve files from. |
| void csilk_app_use | ( | csilk_app_t * | app, |
| csilk_handler_t | h | ||
| ) |
Register a global middleware that runs on every route.
Middleware is executed in registration order for every request, before the route-specific handler. The onion model applies — code before csilk_next() runs on the way in, code after runs on the way out.
| app | Application handle. |
| h | Middleware handler function. |
Register a global middleware that runs on every route.
Global middleware runs before route-specific middleware and handlers for every request. Built-in recovery and logger middleware are registered automatically by csilk_app_new().
| app | Application instance. |
| h | Middleware handler function. |
| void csilk_app_use_group | ( | csilk_app_t * | app, |
| const char * | prefix, | ||
| csilk_handler_t | h | ||
| ) |
Register a middleware that runs only on a specific prefix group.
Group middleware is prepended to routes whose path matches prefix. For example, a middleware registered with prefix "/api" runs on all "/api/..." routes but not on "/health".
| app | Application handle. |
| prefix | URL path prefix (e.g., "/api"). |
| h | Middleware handler function. |
Register a middleware that runs only on a specific prefix group.
Creates (or finds) a route group for the given prefix and adds the middleware to it. The middleware runs for any route whose path starts with the given prefix.
| app | Application instance. |
| prefix | URL prefix (e.g., "/api/admin"). |
| h | Middleware handler function. |