Expand description
Reusable HTTP runtime and service boundary.
This module provides a transport-owning HTTP runtime that downstream Rust projects can embed without importing internal modules or depending directly on Hyper.
§Architecture
let server = Server::builder()
.runtime(RuntimeConfig::default())
.build()?;
let handle = server.start_with_service(my_service).await?;
handle.ready().await?;
// server is accepting connections
handle.shutdown();
// server drains and stops
handle.wait().await?;The runtime owns:
- Listener acceptance
- HTTP/1 parsing
- Request conversion to canonical types
- Response normalization
- Timeout enforcement
- Connection and file-stream permits
- Connection/task tracking
- Graceful shutdown with drain deadline
- Forced shutdown with task cancellation
Services own:
- Request handling logic
- Response construction
§Public types
Server— the main entry point for embeddingServerBuilder— configured builder for the serverServerHandle— control handle for a running serverRuntimeConfig— transport-level configurationService— the service traitservice_fn— create a service from a closureStaticService— hardened static file serviceServerError— startup and lifecycle errorsServiceError— per-request service errorsShutdownResult— outcome of a shutdown operationLifecycleState— server lifecycle state
Re-exports§
pub use crate::primitives::request::Request;pub use config::try_from_serve_config;pub use config::RuntimeConfig;pub use config::RuntimeConfigBuilder;pub use errors::ServerError;pub use errors::ShutdownResult;pub use handle::ServerHandle;pub use lifecycle::LifecycleState;pub use service::service_fn;pub use service::service_fn_head;pub use service::service_fn_with_policy;pub use service::Service;pub use service::ServiceError;pub use service::ServiceFn;pub use static_service::StaticService;pub use static_service::StaticServiceBuilder;
Modules§
- config
- Runtime configuration for the HTTP server.
- connection
- Connection execution pipeline.
- errors
- Public runtime error types.
- handle
- Server lifecycle handle.
- lifecycle
- Lifecycle state machine for the HTTP server.
- service
- Transport-independent service abstraction.
- static_
service - Canonical, confined static-file service.
Structs§
- Runtime
State - Transport state shared by every connection in one running server.
- Server
- A reusable HTTP runtime server.
- Server
Builder - Builder for constructing a
Server.