monolake_services/http/
mod.rs

1//! HTTP protocol handling and services module.
2//!
3//! This module provides a comprehensive set of components for handling HTTP connections,
4//! processing requests, and managing responses. It includes core services, various handlers,
5//! protocol detection, and utility functions for working with HTTP.
6//!
7//! # Key Components
8//!
9//! ## Submodules
10//!
11//! - [`core`]: Contains the core HTTP service implementation, including `HttpCoreService`.
12//! - [`handlers`]: Provides various HTTP request handlers for different aspects of request
13//!   processing.
14//! - [`detect`]: Implements HTTP version detection functionality.
15//!
16//! ## Structs and Types
17//!
18//! - [`HttpCoreService`]: The main service for handling HTTP/1.1 and HTTP/2 connections.
19//! - [`HttpServerTimeout`]: Configuration for various HTTP server timeout settings.
20//!
21//! # Features
22//!
23//! - Support for both HTTP/1.1 and HTTP/2 protocols
24//! - Modular design with separate handlers for different aspects of HTTP processing
25//! - HTTP version detection capabilities
26//! - Configurable timeout settings for various stages of request handling
27//! - Utility functions and constants for common HTTP operations
28//!
29//! # Performance Considerations
30//!
31//! - The core service and handlers are designed for efficient processing of HTTP requests
32//! - Connection keep-alive and HTTP/2 multiplexing are supported for improved performance
33//! - Version detection allows for optimized handling based on the HTTP version
34//!
35//! # Error Handling
36//!
37//! - Each component implements its own error handling strategy
38//! - The core service provides high-level error handling for the entire request lifecycle
39//!
40//! # Customization
41//!
42//! - The modular design allows for easy extension and customization of HTTP handling behavior
43//! - Custom handlers can be implemented and integrated into the `HttpCoreService`
44use http::HeaderValue;
45use serde::{Deserialize, Serialize};
46
47pub use self::core::{HttpCoreService, HttpServerTimeout};
48pub mod handlers;
49
50pub mod core;
51pub mod detect;
52mod util;
53
54pub(crate) const CLOSE: &str = "close";
55pub(crate) const KEEPALIVE: &str = "Keep-Alive";
56#[allow(clippy::declare_interior_mutable_const)]
57pub(crate) const CLOSE_VALUE: HeaderValue = HeaderValue::from_static(CLOSE);
58#[allow(clippy::declare_interior_mutable_const)]
59pub(crate) const KEEPALIVE_VALUE: HeaderValue = HeaderValue::from_static(KEEPALIVE);
60pub(crate) use util::generate_response;
61
62#[derive(Debug, Copy, Clone, Default, Deserialize, Serialize)]
63#[serde(rename_all = "lowercase")]
64pub enum HttpVersion {
65    Http2,
66    Http11,
67    #[default]
68    Auto,
69}