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//! High-performance HTTP server built on axum.
10//!
11//! This module provides a configurable HTTP server suitable for building
12//! APIs, health endpoints, and metrics servers. It uses axum for ergonomics
13//! and is compatible with Tonic for gRPC.
14//!
15//! ## Features
16//!
17//! - Graceful shutdown support
18//! - Configurable timeouts (request, keep-alive)
19//! - Optional TLS support
20//! - Health check endpoints (`/health/live`, `/health/ready`)
21//! - Metrics endpoint (`/metrics`)
22//! - Tower middleware integration
23//!
24//! ## Example
25//!
26//! ```rust,no_run
27//! use hyperi_rustlib::http_server::{HttpServer, HttpServerConfig};
28//! use axum::{Router, routing::get};
29//!
30//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
31//! let config = HttpServerConfig {
32//!     bind_address: "0.0.0.0:8080".to_string(),
33//!     ..Default::default()
34//! };
35//!
36//! let app = Router::new()
37//!     .route("/", get(|| async { "Hello, World!" }));
38//!
39//! let server = HttpServer::new(config);
40//! server.serve(app).await?;
41//! # Ok(())
42//! # }
43//! ```
44
45mod config;
46mod error;
47mod server;
48
49pub use config::HttpServerConfig;
50pub use error::HttpServerError;
51pub use server::HttpServer;
52
53// Re-export axum types users commonly need
54pub use axum::{
55    Extension, Router,
56    extract::{Path, Query, State},
57    response::{IntoResponse, Json, Response},
58    routing::{delete, get, post, put},
59};
60
61/// Result type for HTTP server operations.
62pub type Result<T> = std::result::Result<T, HttpServerError>;