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
//! HTTP request extractors for the `MoosicBox` web server
//!
//! This module provides extractors that implement the `FromRequest` trait,
//! allowing automatic extraction of data from HTTP requests in handler functions.
//!
//! # Dual-Mode Support
//!
//! All extractors support both synchronous and asynchronous extraction:
//!
//! * **Actix backend**: Uses synchronous extraction to avoid Send bounds issues
//! * **Simulator backend**: Uses async extraction for deterministic testing
//!
//! # Available Extractors
//!
//! ## Serde-based Extractors (require `serde` feature)
//!
//! * [`Query<T>`] - Extract URL query parameters using `serde_urlencoded`
//! * [`Json<T>`] - Extract JSON request body using `serde_json`
//! * [`Path<T>`] - Extract URL path parameters with flexible mapping
//! * [`Header<T>`] - Extract typed headers with multiple strategies
//!
//! ## Core Extractors (always available)
//!
//! * [`State<T>`] - Extract application state with backend-specific storage
//!
//! # Error Handling
//!
//! Each extractor provides comprehensive error types:
//!
//! * [`QueryError`] - Query parameter parsing and validation errors
//! * [`JsonError`] - JSON parsing and content-type validation errors
//! * [`PathError`] - Path segment extraction and deserialization errors
//! * [`HeaderError`] - Header parsing and type conversion errors
//! * [`StateError`] - State lookup and initialization errors
//!
//! # Usage Examples
//!
//! ```rust,ignore
//! use switchy_web_server::extractors::{Query, Json, Path, Header, State};
//! use serde::Deserialize;
//!
//! #[derive(Deserialize)]
//! struct SearchParams {
//! q: String,
//! limit: Option<u32>,
//! }
//!
//! #[derive(Deserialize)]
//! struct CreateUser {
//! name: String,
//! email: String,
//! }
//!
//! // Extract query parameters
//! async fn search(Query(params): Query<SearchParams>) -> Result<HttpResponse, Error> {
//! // Use params.q and params.limit
//! Ok(HttpResponse::ok())
//! }
//!
//! // Extract JSON body
//! async fn create_user(Json(user): Json<CreateUser>) -> Result<HttpResponse, Error> {
//! // Use user.name and user.email
//! Ok(HttpResponse::ok())
//! }
//!
//! // Extract path parameters
//! async fn get_user(Path(user_id): Path<u64>) -> Result<HttpResponse, Error> {
//! // Use user_id from URL path
//! Ok(HttpResponse::ok())
//! }
//!
//! // Extract headers
//! async fn auth_handler(Header(auth): Header<String>) -> Result<HttpResponse, Error> {
//! // Use authorization header value
//! Ok(HttpResponse::ok())
//! }
//!
//! // Extract application state
//! async fn with_state(State(db): State<DatabasePool>) -> Result<HttpResponse, Error> {
//! // Use shared database pool
//! Ok(HttpResponse::ok())
//! }
//!
//! // Combine multiple extractors
//! async fn complex_handler(
//! Path(id): Path<u64>,
//! Query(params): Query<SearchParams>,
//! Json(data): Json<CreateUser>,
//! Header(auth): Header<String>,
//! State(db): State<DatabasePool>,
//! ) -> Result<HttpResponse, Error> {
//! // Use all extracted data together
//! Ok(HttpResponse::ok())
//! }
//! ```
//!
//! # Feature Gates
//!
//! Most extractors require the `serde` feature to be enabled. Only the [`State`]
//! extractor is available without additional features, as it doesn't require
//! serialization/deserialization capabilities.
/// Query parameter extraction module
/// JSON body extraction module
/// Path parameter extraction module
/// HTTP header extraction module
/// Application state extraction module
// Re-export extractors for convenient access
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
/// Prelude module for convenient importing of common extractor types
///
/// This module re-exports the most commonly used extractor types and their
/// associated error types, allowing for convenient glob imports.
///
/// # Usage
///
/// ```rust,ignore
/// use switchy_web_server::extractors::prelude::*;
///
/// // Now you can use Query, Json, Path, Header, State directly
/// async fn handler(
/// Query(params): Query<MyParams>,
/// Json(data): Json<MyData>,
/// ) -> Result<HttpResponse, Error> {
/// // Handler implementation
/// Ok(HttpResponse::ok())
/// }
/// ```