Skip to main content

hyperi_rustlib/http_server/
mod.rs

1// Project:   hyperi-rustlib
2// File:      src/http_server/mod.rs
3// Purpose:   High-performance HTTP server with axum
4// Language:  Rust
5//
6// License:   BUSL-1.1
7// Copyright: (c) 2026 HYPERI PTY LIMITED
8
9//! HTTP server built on axum. Compatible with Tonic for gRPC.
10//!
11//! ## Features
12//!
13//! - Graceful shutdown
14//! - Configurable request timeout, in-flight cap, Tower middleware
15//! - Health endpoints (`/healthz`, `/readyz`, plus `/health/*` aliases)
16//!
17//! In-process TLS and a `/metrics` endpoint are NOT wired here -- see
18//! [`HttpServerConfig`]. Terminate TLS at the ingress / mesh; metrics are
19//! served by `MetricsManager` on its own listener.
20//!
21//! ## Example
22//!
23//! ```rust,no_run
24//! use hyperi_rustlib::http_server::{HttpServer, HttpServerConfig};
25//! use axum::{Router, routing::get};
26//!
27//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
28//! let config = HttpServerConfig {
29//!     bind_address: "0.0.0.0:8080".to_string(),
30//!     ..Default::default()
31//! };
32//!
33//! let app = Router::new()
34//!     .route("/", get(|| async { "Hello, World!" }));
35//!
36//! let server = HttpServer::new(config);
37//! server.serve(app).await?;
38//! # Ok(())
39//! # }
40//! ```
41
42mod config;
43mod error;
44mod server;
45
46pub use config::HttpServerConfig;
47pub use error::HttpServerError;
48pub use server::HttpServer;
49
50// Re-export axum types users commonly need
51pub use axum::{
52    Extension, Router,
53    extract::{Path, Query, State},
54    response::{IntoResponse, Json, Response},
55    routing::{delete, get, post, put},
56};
57
58/// Result type for HTTP server operations.
59pub type Result<T> = std::result::Result<T, HttpServerError>;