Skip to main content

Crate mechanics_http_server

Crate mechanics_http_server 

Source
Expand description

Opportunistic HTTP/3 server support for mechanics-family services.

This crate provides two additive building blocks for binaries that already own their HTTP/1.1 and HTTP/2 TCP+TLS listener: an opt-in HTTP/3 QUIC listener and a tower middleware layer that emits Alt-Svc on the existing TCP+TLS path.

Activation is controlled by Http3ServerConfig::bind_h3. When it is None, Http3Server::start returns an inert handle immediately: no UDP socket is opened and no quinn::Endpoint is constructed. When it is Some, this crate binds that UDP address and routes HTTP/3 requests into the supplied tower service.

TLS material is supplied by the caller as rustls::pki_types::CertificateDer and rustls::pki_types::PrivateKeyDer. The QUIC-side TLS configuration uses the aws-lc-rs rustls provider and ALPN h3 only. This server crate deliberately has no webpki-roots dependency and no ring dependency.

HTTP/1.1, HTTP/2 over TCP+TLS, and cleartext HTTP/1.1 remain the consumer binary’s responsibility. This crate does not construct or alter those listeners.

Modules§

axum_compat
Compatibility helpers for routing HTTP/3 requests into axum.

Structs§

AltSvcLayer
Tower layer that inserts an HTTP/3 Alt-Svc response header.
AltSvcService
Service produced by AltSvcLayer.
H3RequestBody
Streaming request body received from an HTTP/3 client.
Http3Handle
Handle returned by Http3Server::start.
Http3Server
Optional HTTP/3 listener that runs alongside an existing TCP+TLS server.
Http3ServerConfig
Configuration for the HTTP/3 listener.

Enums§

Error
Errors returned by mechanics-http-server.
H3RequestBodyError
Error returned while receiving an HTTP/3 request body.

Functions§

alt_svc_layer
Build an AltSvcLayer for h3=":<port>"; ma=<max-age>.
default_zero_rtt_methods
Default methods considered safe for replayable 0-RTT requests.
is_zero_rtt_safe
Return whether method is allowed by the configured 0-RTT policy.

Type Aliases§

Result
Crate-local result alias.