Skip to main content

Module server

Module server 

Source
Expand description

§modo::server

HTTP server startup, host-based routing, and graceful shutdown.

Provides:

  • Config — bind address and shutdown timeout, loaded from YAML.
  • http() — binds a TCP listener and returns an HttpServer handle.
  • HttpServer — opaque server handle that implements crate::runtime::Task for use with the crate::run! macro.
  • HostRouter — routes requests to different axum routers by Host header; supports exact matches and single-level wildcard subdomains.
  • MatchedHost — axum extractor for the subdomain captured by a wildcard HostRouter pattern.

§Quick start

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.
HostRouter
Routes requests to different axum Routers based on the Host header.
HttpServer
An opaque handle to the running HTTP server.
MatchedHost
Information about a wildcard host match.

Functions§

http
Bind a TCP listener and start serving router.