rust_web_server/lib.rs
1//! # rust-web-server
2//!
3//! A static file web server and HTTP toolkit written in Rust.
4//! Supports HTTP/3 (QUIC), HTTP/2, and HTTP/1.1.
5//!
6//! ## Use as a library
7//!
8//! Add to `Cargo.toml`:
9//!
10//! ```toml
11//! [dependencies]
12//! rust-web-server = "17"
13//! ```
14//!
15//! ## Quick start: add a custom route
16//!
17//! ```rust,no_run
18//! use rust_web_server::controller::Controller;
19//! use rust_web_server::request::{METHOD, Request};
20//! use rust_web_server::response::{Response, STATUS_CODE_REASON_PHRASE};
21//! use rust_web_server::range::Range;
22//! use rust_web_server::mime_type::MimeType;
23//! use rust_web_server::server::ConnectionInfo;
24//!
25//! pub struct PingController;
26//!
27//! impl Controller for PingController {
28//! fn is_matching(request: &Request, _: &ConnectionInfo) -> bool {
29//! request.method == METHOD.get && request.request_uri == "/ping"
30//! }
31//!
32//! fn process(_: &Request, mut response: Response, _: &ConnectionInfo) -> Response {
33//! response.status_code = *STATUS_CODE_REASON_PHRASE.n200_ok.status_code;
34//! response.reason_phrase = STATUS_CODE_REASON_PHRASE.n200_ok.reason_phrase.to_string();
35//! response.content_range_list = vec![
36//! Range::get_content_range(b"pong".to_vec(), MimeType::TEXT_PLAIN.to_string())
37//! ];
38//! response
39//! }
40//! }
41//! ```
42//!
43//! See [DEVELOPER.md](https://github.com/bohdaq/rust-web-server/blob/main/DEVELOPER.md)
44//! for the full building blocks reference and use case examples.
45
46pub mod app;
47#[cfg(feature = "http2")]
48pub mod async_state;
49pub mod compression;
50pub mod cookie;
51pub mod error;
52pub mod extract;
53pub mod metrics;
54pub mod middleware;
55pub mod rate_limit;
56pub mod router;
57pub mod state;
58pub mod test_client;
59pub mod application;
60pub mod body;
61pub mod client_hint;
62pub mod controller;
63pub mod core;
64pub mod cors;
65pub mod entry_point;
66pub mod ext;
67pub mod header;
68pub mod http;
69pub mod json;
70pub mod language;
71pub mod log;
72pub mod mime_type;
73pub mod null;
74pub mod range;
75pub mod request;
76pub mod response;
77pub mod server;
78pub mod symbol;
79pub mod thread_pool;
80pub mod url;
81pub mod websocket;
82
83#[cfg(feature = "http2")]
84#[doc(hidden)]
85pub mod tls;
86
87#[cfg(feature = "http2")]
88#[doc(hidden)]
89pub mod h2_handler;
90
91#[cfg(feature = "http3")]
92#[doc(hidden)]
93pub mod h3_handler;