Expand description
HTTP server startup and graceful shutdown.
This module provides:
Config— bind address and shutdown timeout, loaded from YAML.http()— starts a TCP listener and returns anHttpServerhandle.HttpServer— opaque server handle that implementscrate::runtime::Taskfor use with thecrate::run!macro.HostRouter— host-based request routing to different axum routers.MatchedHost— extractor for the subdomain matched by a wildcard pattern.
§Example
use modo::server::{Config, http};
#[tokio::main]
async fn main() -> modo::Result<()> {
let config = Config::default();
let router = modo::axum::Router::new();
let server = http(router, &config).await?;
modo::run!(server).await
}Structs§
- Config
- HTTP server configuration.
- Host
Router - Routes requests to different axum
Routers based on theHostheader. - Http
Server - An opaque handle to the running HTTP server.
- Matched
Host - Information about a wildcard host match.
Functions§
- http
- Bind a TCP listener and start serving
router.