|
| routing::Middleware | orbit::middleware::compress (CompressOptions options={}) |
| | Returns a middleware that compresses response bodies with brotli, zstd or gzip, whichever the client accepts and the server prefers.
|
| |
| routing::Middleware | orbit::middleware::cors (CorsOptions options=CorsOptions{}) |
| | Returns a middleware that handles CORS.
|
| |
| auto | orbit::middleware::csrf_protection (const std::string &cookie_name="csrf_token", const std::string &header_name="X-CSRF-Token") |
| | Helper to create a CSRF protection middleware handler.
|
| |
| routing::Middleware | orbit::middleware::jwt_auth (JwtOptions options) |
| | Verifies an Authorization: Bearer JWT and stores its claims in req.user.
|
| |
| routing::Middleware | orbit::middleware::jwt_auth (const std::string &secret_key) |
| | Shorthand for an HS256-only jwt_auth() with this secret.
|
| |
| routing::Middleware | orbit::middleware::request_id (RequestIdOptions options={}) |
| | Gives every request an ID (req.request_id) and echoes it in the response header, so a client report can be matched to server logs.
|
| |
| routing::Middleware | orbit::middleware::tracing (TracingOptions options={}) |
| | W3C Trace Context: continues the trace from an incoming traceparent header (or starts a new one), sets req.trace_id and req.span_id, and reports each request as a Span.
|
| |
| routing::Middleware | orbit::middleware::access_log (AccessLogOptions options={}) |
| | Logs one line per request when its response is sent: method, path, status, response bytes, duration, client IP, user agent, and the request/trace IDs when request_id() / tracing() are used. In JSON log format these are separate fields.
|
| |
| routing::Middleware | orbit::middleware::proxy (ProxyOptions options) |
| | Returns a middleware that proxies requests to a single target URL (ip/hostname and port).
|
| |
| routing::Middleware | orbit::middleware::proxy (const std::string &target_host, int target_port) |
| | Returns a middleware that proxies requests to a single target URL.
|
| |
| routing::Middleware | orbit::middleware::load_balancer (LoadBalancerOptions options) |
| | Returns a middleware that load-balances requests across multiple upstream nodes.
|
| |
| routing::Middleware | orbit::middleware::load_balancer (const std::vector< TargetNode > &nodes) |
| | Returns a middleware that load-balances requests across multiple upstream nodes.
|
| |
| routing::Middleware | orbit::middleware::security_headers (SecurityHeadersOptions options={}) |
| | Adds common security response headers (HSTS, nosniff, frame and referrer policies, COOP, optional CSP). They are defaults: a handler that sets the same header keeps its own value.
|
| |
| routing::Middleware | orbit::middleware::static_files (const std::string &directory, StaticFilesOptions options={}) |
| | Returns a middleware that serves static files from a directory.
|
| |
| routing::Middleware | orbit::middleware::trusted_proxies (TrustedProxyOptions options) |
| | Sets req.client_ip from forwarding headers, but only for requests that arrive from a trusted proxy.
|
| |
| routing::Middleware | orbit::middleware::validate_json (const std::vector< SchemaField > &schema) |
| | Returns a middleware that parses and validates a JSON request body.
|
| |
Built-in middleware components for Orbit HTTP server.
Returns a middleware that compresses response bodies with brotli, zstd or gzip, whichever the client accepts and the server prefers.
The coding is negotiated from Accept-Encoding (see negotiate_coding()). Every compressible response gets "Vary: Accept-Encoding", so shared caches keep the variants apart. Responses that already have a Content-Encoding, ask for Cache-Control: no-transform, are small, are already-compressed media, or are streamed are left alone. A strong ETag on a compressed body is made weak, since the bytes differ from the uncompressed variant.
- Returns
- routing::Middleware The compression middleware handler.
Verifies an Authorization: Bearer JWT and stores its claims in req.user.
Supported algorithms are HS256, RS256 and ES256. Every key has exactly one algorithm, and the token's "alg" must match the key it is verified with, so a token cannot switch algorithms (e.g. present an RSA public key as an HMAC secret, or use "none"). HMAC signatures are compared in constant time; exp and nbf are enforced when present (and exp is required when require_exp is set).
- Exceptions
-
| std::invalid_argument | if no key is configured or a key is unusable. |
Returns a middleware that serves static files from a directory.
Handles GET and HEAD. If a file is found, it is served and the pipeline is stopped; otherwise the pipeline continues. Paths that resolve outside the directory (including through symlinks) get 403, and dotfiles are hidden unless StaticFilesOptions::serve_dotfiles is set.
Responses carry ETag, Last-Modified, Cache-Control and Accept-Ranges. If-None-Match / If-Modified-Since produce 304, and a single byte Range produces 206 (or 416 when it lies outside the file).
- Parameters
-
| directory | The directory containing static files. |
| options | Index file, dotfile and caching behaviour. |
- Returns
- routing::Middleware The static files middleware handler.
Sets req.client_ip from forwarding headers, but only for requests that arrive from a trusted proxy.
The header is read right to left, skipping trusted proxies; the first address that is not one of them is the client. Requests from anyone else keep their socket address, so clients cannot spoof their IP. The socket address stays available as req.peer_ip.
Register it before middleware that uses client_ip (rate limiting, logging).
- Exceptions
-
| std::invalid_argument | if an entry in proxies is malformed. |