Expand description
§modo::server
HTTP server startup, host-based routing, and graceful shutdown.
Provides:
Config— bind address and shutdown timeout, deserialized from theserverYAML section.http()— binds a TCP listener, spawns the server on a background task, and returns anHttpServerhandle.HttpServer— opaque server handle that implementscrate::runtime::Taskso it composes with thecrate::run!macro for coordinated graceful shutdown.HostRouter— routes requests to different axum routers byHostheader; supports exact matches and single-level wildcard subdomains with an optional fallback. ImplementsInto<axum::Router>so it plugs directly intohttp().MatchedHost— axum extractor that exposes the subdomain captured by a wildcardHostRouterpattern (plus the pattern itself).
Trailing slashes are stripped from request paths before routing, so /app
and /app/ resolve to the same handler (the root / is preserved).
§Quick start
use modo::{Config, Result};
use modo::axum::Router;
#[tokio::main]
async fn main() -> Result<()> {
let config: Config = modo::config::load("config/")?;
let app = Router::new();
let server = modo::server::http(app, &config.server).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.