Skip to main content

ferrohealth_server/
lib.rs

1// SPDX-FileCopyrightText: Cadasto B.V.
2// SPDX-License-Identifier: BUSL-1.1
3
4//! The HTTP server plumbing of the FerroHEALTH products.
5//!
6//! [`stack::app`] wraps a product's router in the one stack every server
7//! runs, under its base path, and [`stack::Stack`] also mounts routes
8//! beside the base path and the product's fallback inside it:
9//!
10//! - [`request_id`]: the server mints its own id for every request and logs
11//!   it; a client's `X-Request-Id` is echoed and never logged.
12//! - [`mod@panic`]: a handler panic becomes a `500` with a body the product
13//!   supplies, and the panic message reaches neither the body nor the log.
14//! - the request timeout (`408`) and the body limit (`413`);
15//! - [`overload`]: past `max_concurrent_requests` (256 by default, always
16//!   on) a request waits up to `admission_wait` (100 ms) in a queue of
17//!   `max_waiting_requests` (256), then is answered `503` with
18//!   `Retry-After`; the health routes are never refused or queued;
19//! - [`client_address`]: the address a request came from, read behind the
20//!   trusted proxies;
21//! - gzip and Brotli response compression, on by default, and the decoding
22//!   of a gzip or Brotli request body under the same body limit, off by
23//!   default (`request_decompression`);
24//! - [`api_headers`]: the security headers of an API response, outermost,
25//!   so the stack's own refusals carry them too;
26//! - the request log of `ferrohealth-telemetry`;
27//! - [`health`]: `/health`, `/health/liveness`, `/health/readiness` and,
28//!   when the product supplies it, `/health/info`.
29//!
30//! [`problem`] writes RFC 9457 problem details, for a product's own error
31//! bodies outside FHIR and, when the product opts in, for the stack's
32//! refusals and panics.
33//!
34//! [`caller_rate`] is the per-caller rate limit a product mounts inside its
35//! authentication.
36//!
37//! [`serve::serve`] runs the app until `SIGTERM` or `SIGINT`, then withdraws
38//! readiness, waits the drain delay and finishes the requests in flight
39//! within a bound, over TLS when `[server.tls]` is set ([`tls`]);
40//! [`serve::run_all`] serves several listeners under one signal.
41//! [`tls_client`] reads the TLS material of a product's outbound calls,
42//! `telemetry` (feature `otlp`) builds a product's telemetry with its OTLP
43//! collector dialed over that TLS,
44//! and `revocation` (feature `revocation`) checks every certificate an
45//! outbound peer presents by CRL, then OCSP, before any data is sent.
46//! [`healthcheck`] is the container probe, [`cli::Common`] and
47//! [`cli::ConfigArgs`] the subcommands and arguments every binary shares,
48//! [`run::Run`] the run path around them (the parse, the runtime and the
49//! error chain),
50//! [`build_info`] the build facts and the boot banner,
51//! and `console` (feature `console`) the browser security headers of an
52//! operator console, with `same_origin` the check of its state-changing
53//! requests.
54//!
55//! No specification governs the stack: our own design, with the status
56//! codes and `Retry-After` of RFC 9110.
57
58pub mod api_headers;
59pub mod build_info;
60pub mod caller_rate;
61pub mod cli;
62pub mod client_address;
63#[cfg(feature = "console")]
64pub mod console;
65mod decoding;
66mod edge;
67pub mod health;
68pub mod healthcheck;
69pub mod overload;
70pub mod panic;
71pub mod problem;
72pub mod refusal;
73pub mod request_id;
74#[cfg(feature = "revocation")]
75pub mod revocation;
76pub mod run;
77#[cfg(feature = "console")]
78pub mod same_origin;
79pub mod section;
80pub mod serve;
81pub mod stack;
82#[cfg(feature = "otlp")]
83pub mod telemetry;
84pub mod tls;
85pub mod tls_client;