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
46// Allows `::rust_web_server::…` paths to resolve from within this crate's own
47// tests, which is required by proc-macro derive output that uses that prefix.
48extern crate self as rust_web_server;
49
50pub mod app;
51#[cfg(feature = "auth")]
52pub mod auth;
53
54#[cfg(feature = "macros")]
55pub use rws_macros::{delete, get, patch, post, put, route, FromRequest, Validate};
56#[cfg(feature = "http2")]
57pub mod async_state;
58pub mod session;
59pub mod sse;
60pub mod compression;
61pub mod cookie;
62pub mod error;
63pub mod extract;
64pub mod ip_filter;
65pub mod macros;
66pub mod blocklist;
67pub mod cache;
68pub mod config_reload;
69pub mod feature;
70pub mod maintenance;
71pub mod metrics;
72pub mod mcp;
73pub mod request_log;
74pub mod otel;
75#[cfg(feature = "acme")]
76pub mod acme;
77pub mod middleware;
78pub mod rate_limit;
79pub mod router;
80pub mod state;
81pub mod test_client;
82pub mod application;
83pub mod body;
84pub mod client_hint;
85pub mod controller;
86pub mod core;
87pub mod cors;
88pub mod entry_point;
89pub mod ext;
90pub mod header;
91pub mod http;
92pub mod json;
93pub mod language;
94pub mod log;
95pub mod mime_type;
96pub mod null;
97pub mod range;
98pub mod request;
99pub mod response;
100pub mod server;
101pub mod symbol;
102pub mod thread_pool;
103pub mod url;
104pub mod proxy;
105pub mod rewrite;
106pub mod tcp_proxy;
107pub mod udp_proxy;
108pub mod ws_proxy;
109pub mod validate;
110pub mod virtual_host;
111pub mod websocket;
112
113#[cfg(feature = "http2")]
114#[doc(hidden)]
115pub mod tls;
116
117#[cfg(feature = "http2")]
118#[doc(hidden)]
119pub mod h2_handler;
120
121#[cfg(feature = "http3")]
122#[doc(hidden)]
123pub mod h3_handler;