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
220
221
222
223
224
225
226
227
//! # 🪶 Feather: Synchronous DX-First Minimal Web Framework for Rust
//!
//! Feather is a lightweight, middleware-first web framework for Rust, inspired by Express.js but
//! designed for Rust's performance and safety. Build fast, synchronous web applications without async complexity.
//!
//! ## Quick Start
//!
//! Add to `Cargo.toml`:
//! ```toml
//! [dependencies]
//! feather = "0.8"
//! ```
//!
//! Hello world in 7 lines:
//! ```rust,ignore
//! use feather::prelude::*
//! fn main(){
//! let mut app = App::new();
//! app.get("/", middleware!(|_req, res, _ctx| {
//! res.finish_text("Hello, Feather!")
//! }));
//! app.listen("127.0.0.1:5050");
//! }
//!
//! ```
//!
//! ## Why Feather?
//!
//! - **Fully Synchronous**: No async/await complexity. Built on lightweight coroutines for excellent performance.
//! - **Express.js Inspired**: Familiar API with `app.get()`, `app.post()`, middleware chains.
//! - **DX First**: Minimal boilerplate, clear APIs, easy to learn and use.
//! - **Built-in Features**: Routing, middleware, state management, error handling, JWT auth.
//! - **Multithreaded by Default**: Powered by Feather-Runtime for high concurrency.
//!
//! ## Comprehensive Guides
//!
//! Feather comes with detailed guides for every aspect:
//!
//! - **[Getting Started](guides::getting_started)** - Setup and core concepts
//! - **[Routing](guides::routing)** - HTTP methods, paths, and handlers
//! - **[Middlewares](guides::middlewares)** - Request processing pipelines
//! - **[State Management](guides::state_management)** - Application context and data sharing
//! - **[Error Handling](guides::error_handling)** - Error patterns and recovery
//! - **[Authentication](guides::authentication)** - JWT tokens and protected routes
//! - **[Server Configuration](guides::server_configuration)** - Tuning and optimization
//!
//! ## Common Tasks
//!
//! **Add a route:**
//! ```rust,ignore
//! app.get("/users/:id", middleware!(|req, res, ctx| {
//! // Handle request
//! res.send_text("User details");
//! next!()
//! }));
//! ```
//!
//! **Use middleware:**
//! ```rust,ignore
//! app.use_middleware(middleware!(|req, res, _ctx| {
//! println!("{} {}", req.method, req.uri);
//! next!()
//! }));
//! ```
//!
//! **Manage state:**
//! ```rust,ignore
//! use feather::State;
//! app.context().set_state(State::new(MyConfig { /* ... */ }));
//! // Later in middleware:
//! let config = ctx.get_state::<State<MyConfig>>();
//! ```
//!
//! ## Next Steps
//!
//! Start with the **[Getting Started Guide](guides::getting_started)** for a comprehensive introduction,
//! or jump to any specific guide above for deep dives into features you need.
//!
//! ## Missing Feature?
//!
//! Don't see something you need? Check out the GitHub repository for issues, feature requests, and contribution guidelines.
//! Don't hesitate to open an issue or submit a pull request!
//!
//! ---
// --- IMPORTS START ---
/// Comprehensive guides and tutorials for Feather.
///
/// This module contains detailed guides for various aspects of the Feather framework,
/// including routing, middleware, state management, and more.
pub use ;
pub use ;
use Error;
pub use crateState;
pub use crateMiddlewareResult;
pub use cratebuiltins;
pub use ;
pub use ServerConfig;
pub use ;
// --- IMPORTS END ---
/// This is just a type alias for `Result<MiddlewareResult, Box<dyn Error>>;`
/// Outcome is used in All middlewares as a return type.
pub type Outcome = ;
/// This macro is just a syntactic sugar over the `Ok(MiddlewareResult::Next)`
///
/// **Behavior**: Continues execution to the next middleware in the current chain.
/// If used in the last middleware of the global chain, the engine proceeds to route matching.
/// This macro is just a syntactic sugar over the `Ok(MiddlewareResult::NextRoute)`
///
/// **Behavior**: Skips the current middleware stack or route handler.
/// - In Global Middleware: Jumps straight to the Routing phase.
/// - In a Route: Skips to the next matching route (useful conditional routing).
/// This macro is just a syntactic sugar over the `Ok(MiddlewareResult::End)`
///
/// **Behavior**: Instantly halts all further processing (skipping remaining
/// middleware and routing) and sends the current state of the `Response` to the client.<br>
/// **Warning**: Ensure you have populated the `Response` (status, body, etc.) before
/// calling `end!`. Otherwise it will send a empty Response with a 200 code.
/// The `middleware!` macro allows you to define middleware functions concisely without repeating type signatures.
///
/// # Usage
///
/// Use the argument form to access request, response, and context objects:
///
/// ```rust,ignore
/// app.get("/", middleware!(|req, res, ctx| {
/// res.send_text("Hello, world!");
/// next!()
/// }));
/// ```
///
/// This macro expands to a closure with the correct types for Feather's middleware system.
pub use middleware_fn;
pub use Claim;
pub use jwt_required;