Skip to main content

http_handle/
lib.rs

1// Crate-wide unsafe policy: deny by default. Specific authorized sites
2// (libc::sendfile in perf_server::try_sendfile_unix, process-env mutation
3// in tenant_isolation and runtime_autotune tests) carry an explicit
4// `#[allow(unsafe_code)]` attribute with a justifying comment. Using
5// `deny` rather than `forbid` so those targeted exceptions actually
6// compile under Rust 2024.
7#![deny(unsafe_code)]
8// Rustdoc hygiene: catch broken intra-doc links, bare URLs, and
9// unindented examples at doc-build time so doc rot is loud rather
10// than silent. `missing_docs` is already enforced by the rust lint
11// section in Cargo.toml.
12#![deny(rustdoc::broken_intra_doc_links)]
13#![deny(rustdoc::bare_urls)]
14#![deny(rustdoc::invalid_html_tags)]
15// SPDX-License-Identifier: AGPL-3.0-only
16// Copyright (c) 2023 - 2026 HTTP Handle
17
18// src/lib.rs
19#![doc = include_str!("../README.md")]
20#![doc(
21    html_favicon_url = "https://cloudcdn.pro/http-handle/v1/favicon.ico",
22    html_logo_url = "https://cloudcdn.pro/http-handle/v1/logos/http-handle.svg",
23    html_root_url = "https://docs.rs/http-handle"
24)]
25#![cfg_attr(docsrs, feature(doc_cfg))]
26#![cfg_attr(miri, allow(deprecated_in_future))]
27#![crate_name = "http_handle"]
28#![crate_type = "lib"]
29
30pub mod server;
31
32pub mod request;
33
34pub mod response;
35
36pub mod error;
37
38pub mod language;
39
40pub mod async_runtime;
41
42#[cfg(feature = "async")]
43#[cfg_attr(docsrs, doc(cfg(feature = "async")))]
44pub mod async_server;
45
46#[cfg(feature = "batch")]
47#[cfg_attr(docsrs, doc(cfg(feature = "batch")))]
48pub mod batch;
49
50#[cfg(feature = "streaming")]
51#[cfg_attr(docsrs, doc(cfg(feature = "streaming")))]
52pub mod streaming;
53
54#[cfg(feature = "optimized")]
55#[cfg_attr(docsrs, doc(cfg(feature = "optimized")))]
56pub mod optimized;
57
58#[cfg(feature = "http2")]
59#[cfg_attr(docsrs, doc(cfg(feature = "http2")))]
60pub mod http2_server;
61
62#[cfg(feature = "high-perf")]
63#[cfg_attr(docsrs, doc(cfg(feature = "high-perf")))]
64pub mod perf_server;
65
66#[cfg(feature = "http3-profile")]
67#[cfg_attr(docsrs, doc(cfg(feature = "http3-profile")))]
68pub mod http3_profile;
69
70#[cfg(feature = "distributed-rate-limit")]
71#[cfg_attr(docsrs, doc(cfg(feature = "distributed-rate-limit")))]
72pub mod distributed_rate_limit;
73
74#[cfg(feature = "multi-tenant")]
75#[cfg_attr(docsrs, doc(cfg(feature = "multi-tenant")))]
76pub mod tenant_isolation;
77
78#[cfg(feature = "autotune")]
79#[cfg_attr(docsrs, doc(cfg(feature = "autotune")))]
80pub mod runtime_autotune;
81
82pub mod protocol_state;
83
84#[cfg(feature = "enterprise")]
85#[cfg_attr(docsrs, doc(cfg(feature = "enterprise")))]
86pub mod enterprise;
87
88pub mod observability;
89
90pub use error::ServerError;
91pub use language::{Language, LanguageDetector};
92pub use server::{
93    ConnectionPool, Server, ServerBuilder, ShutdownSignal, ThreadPool,
94};
95
96#[cfg(all(test, miri))]
97mod miri_smoke {
98    use super::*;
99    use std::io::Cursor;
100
101    #[test]
102    fn response_serialization_smoke() {
103        let mut response =
104            response::Response::new(200, "OK", b"miri".to_vec());
105        response.add_header("Content-Type", "text/plain");
106        let mut out = Cursor::new(Vec::<u8>::new());
107        response.send(&mut out).expect("send");
108        assert!(!out.get_ref().is_empty());
109    }
110
111    #[test]
112    fn connection_pool_smoke() {
113        let pool = ConnectionPool::new(1);
114        let first = pool.acquire().expect("acquire");
115        assert_eq!(pool.active_count(), 1);
116        assert!(pool.acquire().is_err());
117        drop(first);
118        assert_eq!(pool.active_count(), 0);
119    }
120}