pub struct HttpsServer { /* private fields */ }server only.Expand description
An HTTPS Trust Tasks server.
Build with HttpsServer::builder, register handlers via
HttpsServerBuilder::on, then Self::serve.
Implementations§
Source§impl HttpsServer
impl HttpsServer
Sourcepub fn builder() -> HttpsServerBuilder
pub fn builder() -> HttpsServerBuilder
Start a new builder.
Sourcepub fn into_router(self) -> Router
pub fn into_router(self) -> Router
Build the axum Router without starting a listener — useful for
integration tests that want to spawn the app inline.
The router applies an explicit DefaultBodyLimit of
MAX_BODY_BYTES (256 KiB) as an audited DoS control (SPEC §12.2): the body is
buffered and parsed before authentication, so an unbounded body would
otherwise be a pre-auth memory-exhaustion vector. JSON nesting depth is
separately bounded by serde_json’s default 128-level recursion limit,
so a pathologically nested body within the size budget fails to parse
(→ malformedRequest) rather than overflowing the stack.
It also applies two liveness controls, both configurable on the
builder (HttpsServerBuilder::request_timeout,
HttpsServerBuilder::max_concurrent_requests):
- a
TimeoutLayer— a request that outlives its budget is abandoned with408 Request Timeoutrather than holding a connection and a task open indefinitely (slowloris); - a
ConcurrencyLimitLayer— requests past the ceiling wait for a permit instead of each pinning a parse buffer, bounding the memory a flood can commit.
Both sit outside the body limit, so they also bound the time and concurrency spent reading a body that is still under the size cap.
Sourcepub async fn serve(self, addr: impl ToSocketAddrs) -> Result<()>
pub async fn serve(self, addr: impl ToSocketAddrs) -> Result<()>
Bind to addr and serve incoming requests. Returns when the
listener stops.
The router returned by Self::into_router carries the body-size,
timeout and concurrency controls; this method adds nothing beyond
binding the listener, so a caller that builds its own listener gets
the same protections.