Skip to main content

modo/server/
mod.rs

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