1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
//! Churust core kernel: the engine, routing, request pipeline, and extractors
//! that power the [Churust](https://crates.io/crates/churust) web framework.
//!
//! Churust is a Ktor-inspired, async-first web framework for Rust. This crate
//! (`churust-core`) is the foundation every other Churust crate builds on. It
//! provides:
//!
//! - A fluent [`Churust::server`] builder ([`AppBuilder`]) for assembling an
//! [`App`] from routes, shared state, middleware, and configuration.
//! - A trie-based [`Router`] supporting static segments, `{param}` captures, and
//! trailing `{name...}` wildcards.
//! - The per-request [`Call`] context — the single object every handler receives.
//! - An onion-style middleware [pipeline] ordered by [`Phase`].
//! - Type-safe [extractors](crate::extract) ([`Path`], [`Query`], [`State`],
//! [`BearerToken`]) plus the [`FromCall`]/[`FromCallParts`] traits that let
//! handlers take typed arguments.
//! - A flexible [`Response`]/[`IntoResponse`] model and a status-carrying
//! [`Error`] type.
//! - Layered [`Config`] loading (defaults < `churust.toml` < `CHURUST_*` env <
//! code) and optional TLS (feature `tls`).
//! - An in-process [`TestClient`] for fast, socket-free integration tests.
//!
//! # Example
//!
//! Build an app, register a route, and exercise it with the in-process test
//! client (no socket is bound, so this runs in any environment):
//!
//! ```
//! use churust_core::{Churust, Call, TestClient};
//! # tokio::runtime::Runtime::new().unwrap().block_on(async {
//! let app = Churust::server()
//! .routing(|r| {
//! r.get("/", |_c: Call| async { "Hello, Churust!" });
//! })
//! .build();
//!
//! let res = TestClient::new(app).get("/").send().await;
//! assert_eq!(res.status().as_u16(), 200);
//! assert_eq!(res.text(), "Hello, Churust!");
//! # });
//! ```
//!
//! To actually serve traffic, call [`App::start`] (binds a socket and serves
//! until Ctrl-C) or [`AppBuilder::start`].
pub use Body;
pub use ;
pub use ;
pub use ;
pub use ;
pub use StateMap;
pub use ;
pub use PathPolicy;
pub use ;
pub use ;
pub use ;
pub use ;
/// Security response headers applied by default. See [`SecurityHeaders`].
pub use SecurityHeaders;
// Percent-decoding for path segments. Internal: the decoding rules are a
// routing detail, and exposing them would invite decoding at the wrong point in
// the pipeline.
/// Percent-decoding and canonicalisation for URL path segments.
/// Cookies: reading a request's, and building `Set-Cookie`.
pub use ;
/// `multipart/form-data` bodies (feature `multipart`).
pub use ;
/// Sessions carried by a cookie.
pub use ;
/// Login, logout, and the two deadlines that end a login.
pub use ;
/// Route guards — predicates that select among routes sharing a method and path.
pub use ;
/// Run a blocking operation without stalling the async runtime.
///
/// Calling a blocking API directly from a handler occupies a runtime worker for
/// its duration; enough concurrent calls and the server stops answering
/// anything. This moves the work to tokio's blocking pool, which is what that
/// pool is for.
///
/// Reach for it around synchronous file I/O, a blocking database driver, or
/// CPU-heavy work such as password hashing.
///
/// ```
/// # tokio::runtime::Runtime::new().unwrap().block_on(async {
/// let sum = churust_core::block(|| (1..=1000).sum::<u64>()).await.unwrap();
/// assert_eq!(sum, 500_500);
/// # });
/// ```
///
/// A panic inside `f` becomes a `500` rather than taking down the worker,
/// matching how a panicking handler is already treated.
pub async
/// Compare two secrets without leaking their contents through timing.
///
/// A plain `==` on strings returns as soon as it finds a differing byte, so the
/// time it takes reveals how much of a guess was correct. Over enough requests
/// that is enough to recover a token or password a byte at a time.
///
/// Use this in [`Auth::basic`](../churust_auth/index.html) callbacks and
/// anywhere else a request-supplied value is checked against a secret.
///
/// The comparison is constant-time **in the contents**, not in the length: an
/// early length check short-circuits, which reveals only the length. That is
/// the same trade every practical implementation makes.
///
/// ```
/// use churust_core::secure_compare;
///
/// assert!(secure_compare("hunter2", "hunter2"));
/// assert!(!secure_compare("hunter2", "hunter3"));
/// ```
/// HTTP/3 over QUIC (feature `http3`).
pub use ;
pub use StaticFiles;
pub use ;