Skip to main content

modo/server/
mod.rs

1//! # modo::server
2//!
3//! HTTP server startup, host-based routing, and graceful shutdown.
4//!
5//! Provides:
6//!
7//! - [`Config`] — bind address and shutdown timeout, loaded from YAML.
8//! - [`http()`] — binds a TCP listener and returns an [`HttpServer`] handle.
9//! - [`HttpServer`] — opaque server handle that implements
10//!   [`crate::runtime::Task`] for use with the [`crate::run!`] macro.
11//! - [`HostRouter`] — routes requests to different axum routers by `Host` header;
12//!   supports exact matches and single-level wildcard subdomains.
13//! - [`MatchedHost`] — axum extractor for the subdomain captured by a wildcard
14//!   `HostRouter` pattern.
15//!
16//! ## Quick start
17//!
18//! ```no_run
19//! use modo::server::{Config, http};
20//!
21//! #[tokio::main]
22//! async fn main() -> modo::Result<()> {
23//!     let config = Config::default();
24//!     let router = modo::axum::Router::new();
25//!     let server = http(router, &config).await?;
26//!     modo::run!(server).await
27//! }
28//! ```
29
30mod config;
31mod host_router;
32mod http;
33
34pub use config::Config;
35pub use host_router::{HostRouter, MatchedHost};
36pub use http::{HttpServer, http};