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//! Trailing slashes are stripped from request paths before routing, so `/app`
17//! and `/app/` resolve to the same handler (the root `/` is preserved).
18//!
19//! ## Quick start
20//!
21//! ```no_run
22//! use modo::server::{Config, http};
23//!
24//! #[tokio::main]
25//! async fn main() -> modo::Result<()> {
26//! let config = Config::default();
27//! let router = modo::axum::Router::new();
28//! let server = http(router, &config).await?;
29//! modo::run!(server).await
30//! }
31//! ```
32
33mod config;
34mod host_router;
35mod http;
36
37pub use config::Config;
38pub use host_router::{HostRouter, MatchedHost};
39pub use http::{HttpServer, http};