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
//! A small, composable async HTTP framework built on Hyper.
//!
//! This crate provides a minimal set of primitives for building HTTP servers
//! with explicit control flow and predictable composition.
//!
//! The core ideas are:
//! - **Handlers as async functions**: request handling logic is expressed as
//! ordinary async functions or closures.
//! - **Structured early exit**: control flow is modeled explicitly using [`Flow`],
//! rather than conflating errors with responses.
//! - **Composable pipelines**: handlers can be chained together to form request
//! processing pipelines.
//!
//! The crate intentionally avoids hidden middleware stacks, global state,
//! or implicit error handling. All control flow is explicit and type-driven.
//!
//! # Core Types
//!
//! - [`Server`]: A thin wrapper around Hyper that accepts TCP connections and
//! dispatches HTTP requests to a handler.
//! - [`Handler`]: An asynchronous function-like trait that processes inputs
//! and shared state.
//! - [`Flow`]: A control-flow type used to model continuation or early exit.
//! - [`Request`] and [`Response`]: Lightweight HTTP request/response types.
//!
//! # Control Flow Model
//!
//! Instead of using `Result<T, E>` for request handling, this crate uses
//! [`Flow<C, E>`]:
//!
//! - [`Flow::Continue`] represents successful continuation.
//! - [`Flow::Exit`] represents an intentional early exit.
//!
//! An exit is not necessarily an error; it is simply a signal that no further
//! handlers should run and a response should be returned immediately.
//!
//! Because [`Flow`] implements the `?` operator, early exits can be propagated
//! ergonomically through handler chains.
//!
//! # Handler Composition
//!
//! Handlers can be chained using [`Handler::then`]:
//!
//! ```ignore
//! let handler = authenticate
//! .then(authorize)
//! .then(handle_request);
//! ```
//!
//! Each handler receives the output of the previous one. If any handler exits
//! early, the remaining handlers are skipped and the exit value is returned
//! as a response.
//!
//! # Example
//!
//! ```ignore
//! async fn handler(req: Request, state: AppState) -> Flow<Response, Error> {
//! if !state.ready {
//! return Flow::Exit(Error::ServiceUnavailable);
//! }
//!
//! Flow::Continue(Response::ok())
//! }
//! ```
//!
//! This handler can be passed directly to [`Server`] without additional adapters.
//!
//! # Design Goals
//!
//! - Make control flow explicit and visible in types
//! - Keep abstractions small and composable
//! - Avoid conflating errors with HTTP responses
//! - Stay close to standard library and Hyper concepts
//!
//! This crate is not a batteries-included web framework. It is a foundation
//! for building one, or for embedding HTTP handling into larger systems.
pub use FromRequest;
pub use IntoResponse;
pub use Request;
pub use Response;
pub use body;
pub use Extract;
pub use ExtractStateful;
pub use Continue;
pub use Exit;
pub use Flow;
pub use Handler;
pub use Layer;
pub use Router;
pub use Server;