spikard 0.2.5 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +34 -1
  3. data/ext/spikard_rb/Cargo.toml +3 -3
  4. data/lib/spikard/app.rb +61 -49
  5. data/lib/spikard/converters.rb +3 -75
  6. data/lib/spikard/handler_wrapper.rb +6 -9
  7. data/lib/spikard/provide.rb +14 -28
  8. data/lib/spikard/response.rb +75 -11
  9. data/lib/spikard/streaming_response.rb +24 -1
  10. data/lib/spikard/testing.rb +1 -1
  11. data/lib/spikard/version.rb +1 -1
  12. data/sig/spikard.rbs +14 -3
  13. data/vendor/bundle/ruby/3.3.0/gems/rake-compiler-dock-1.10.0/build/buildkitd.toml +2 -0
  14. metadata +3 -80
  15. data/vendor/crates/spikard-core/Cargo.toml +0 -40
  16. data/vendor/crates/spikard-core/src/bindings/mod.rs +0 -3
  17. data/vendor/crates/spikard-core/src/bindings/response.rs +0 -133
  18. data/vendor/crates/spikard-core/src/debug.rs +0 -63
  19. data/vendor/crates/spikard-core/src/di/container.rs +0 -726
  20. data/vendor/crates/spikard-core/src/di/dependency.rs +0 -273
  21. data/vendor/crates/spikard-core/src/di/error.rs +0 -118
  22. data/vendor/crates/spikard-core/src/di/factory.rs +0 -538
  23. data/vendor/crates/spikard-core/src/di/graph.rs +0 -545
  24. data/vendor/crates/spikard-core/src/di/mod.rs +0 -192
  25. data/vendor/crates/spikard-core/src/di/resolved.rs +0 -411
  26. data/vendor/crates/spikard-core/src/di/value.rs +0 -283
  27. data/vendor/crates/spikard-core/src/http.rs +0 -153
  28. data/vendor/crates/spikard-core/src/lib.rs +0 -28
  29. data/vendor/crates/spikard-core/src/lifecycle.rs +0 -422
  30. data/vendor/crates/spikard-core/src/parameters.rs +0 -719
  31. data/vendor/crates/spikard-core/src/problem.rs +0 -310
  32. data/vendor/crates/spikard-core/src/request_data.rs +0 -189
  33. data/vendor/crates/spikard-core/src/router.rs +0 -249
  34. data/vendor/crates/spikard-core/src/schema_registry.rs +0 -183
  35. data/vendor/crates/spikard-core/src/type_hints.rs +0 -304
  36. data/vendor/crates/spikard-core/src/validation.rs +0 -699
  37. data/vendor/crates/spikard-http/Cargo.toml +0 -58
  38. data/vendor/crates/spikard-http/src/auth.rs +0 -247
  39. data/vendor/crates/spikard-http/src/background.rs +0 -249
  40. data/vendor/crates/spikard-http/src/bindings/mod.rs +0 -3
  41. data/vendor/crates/spikard-http/src/bindings/response.rs +0 -1
  42. data/vendor/crates/spikard-http/src/body_metadata.rs +0 -8
  43. data/vendor/crates/spikard-http/src/cors.rs +0 -490
  44. data/vendor/crates/spikard-http/src/debug.rs +0 -63
  45. data/vendor/crates/spikard-http/src/di_handler.rs +0 -423
  46. data/vendor/crates/spikard-http/src/handler_response.rs +0 -190
  47. data/vendor/crates/spikard-http/src/handler_trait.rs +0 -228
  48. data/vendor/crates/spikard-http/src/handler_trait_tests.rs +0 -284
  49. data/vendor/crates/spikard-http/src/lib.rs +0 -529
  50. data/vendor/crates/spikard-http/src/lifecycle/adapter.rs +0 -149
  51. data/vendor/crates/spikard-http/src/lifecycle.rs +0 -428
  52. data/vendor/crates/spikard-http/src/middleware/mod.rs +0 -285
  53. data/vendor/crates/spikard-http/src/middleware/multipart.rs +0 -86
  54. data/vendor/crates/spikard-http/src/middleware/urlencoded.rs +0 -147
  55. data/vendor/crates/spikard-http/src/middleware/validation.rs +0 -287
  56. data/vendor/crates/spikard-http/src/openapi/mod.rs +0 -309
  57. data/vendor/crates/spikard-http/src/openapi/parameter_extraction.rs +0 -190
  58. data/vendor/crates/spikard-http/src/openapi/schema_conversion.rs +0 -308
  59. data/vendor/crates/spikard-http/src/openapi/spec_generation.rs +0 -195
  60. data/vendor/crates/spikard-http/src/parameters.rs +0 -1
  61. data/vendor/crates/spikard-http/src/problem.rs +0 -1
  62. data/vendor/crates/spikard-http/src/query_parser.rs +0 -369
  63. data/vendor/crates/spikard-http/src/response.rs +0 -399
  64. data/vendor/crates/spikard-http/src/router.rs +0 -1
  65. data/vendor/crates/spikard-http/src/schema_registry.rs +0 -1
  66. data/vendor/crates/spikard-http/src/server/handler.rs +0 -80
  67. data/vendor/crates/spikard-http/src/server/lifecycle_execution.rs +0 -98
  68. data/vendor/crates/spikard-http/src/server/mod.rs +0 -805
  69. data/vendor/crates/spikard-http/src/server/request_extraction.rs +0 -119
  70. data/vendor/crates/spikard-http/src/sse.rs +0 -447
  71. data/vendor/crates/spikard-http/src/testing/form.rs +0 -14
  72. data/vendor/crates/spikard-http/src/testing/multipart.rs +0 -60
  73. data/vendor/crates/spikard-http/src/testing/test_client.rs +0 -285
  74. data/vendor/crates/spikard-http/src/testing.rs +0 -377
  75. data/vendor/crates/spikard-http/src/type_hints.rs +0 -1
  76. data/vendor/crates/spikard-http/src/validation.rs +0 -1
  77. data/vendor/crates/spikard-http/src/websocket.rs +0 -324
  78. data/vendor/crates/spikard-rb/Cargo.toml +0 -42
  79. data/vendor/crates/spikard-rb/build.rs +0 -8
  80. data/vendor/crates/spikard-rb/src/background.rs +0 -63
  81. data/vendor/crates/spikard-rb/src/config.rs +0 -294
  82. data/vendor/crates/spikard-rb/src/conversion.rs +0 -392
  83. data/vendor/crates/spikard-rb/src/di.rs +0 -409
  84. data/vendor/crates/spikard-rb/src/handler.rs +0 -534
  85. data/vendor/crates/spikard-rb/src/lib.rs +0 -2020
  86. data/vendor/crates/spikard-rb/src/lifecycle.rs +0 -267
  87. data/vendor/crates/spikard-rb/src/server.rs +0 -283
  88. data/vendor/crates/spikard-rb/src/sse.rs +0 -231
  89. data/vendor/crates/spikard-rb/src/test_client.rs +0 -404
  90. data/vendor/crates/spikard-rb/src/test_sse.rs +0 -143
  91. data/vendor/crates/spikard-rb/src/test_websocket.rs +0 -221
  92. data/vendor/crates/spikard-rb/src/websocket.rs +0 -233
@@ -1,228 +0,0 @@
1
- //! Handler trait for language-agnostic request handling
2
- //!
3
- //! This module defines the core trait that all language bindings must implement.
4
- //! It's completely language-agnostic - no Python, Node, or WASM knowledge.
5
-
6
- use axum::{
7
- body::Body,
8
- http::{Request, Response, StatusCode},
9
- };
10
- use serde::{Deserialize, Serialize};
11
- use serde_json::Value;
12
- use std::collections::HashMap;
13
- use std::future::Future;
14
- use std::pin::Pin;
15
-
16
- /// Request data extracted from HTTP request
17
- /// This is the language-agnostic representation passed to handlers
18
- ///
19
- /// Uses Arc for HashMaps to enable cheap cloning without duplicating data.
20
- /// When RequestData is cloned, only the Arc pointers are cloned, not the underlying data.
21
- ///
22
- /// Performance optimization: raw_body stores the unparsed request body bytes.
23
- /// Language bindings should use raw_body when possible to avoid double-parsing.
24
- /// The body field is lazily parsed only when needed for validation.
25
- #[derive(Debug, Clone)]
26
- pub struct RequestData {
27
- pub path_params: std::sync::Arc<HashMap<String, String>>,
28
- pub query_params: Value,
29
- pub raw_query_params: std::sync::Arc<HashMap<String, Vec<String>>>,
30
- pub body: Value,
31
- pub raw_body: Option<bytes::Bytes>,
32
- pub headers: std::sync::Arc<HashMap<String, String>>,
33
- pub cookies: std::sync::Arc<HashMap<String, String>>,
34
- pub method: String,
35
- pub path: String,
36
- /// Resolved dependencies for this request (populated by DependencyInjectingHandler)
37
- #[cfg(feature = "di")]
38
- pub dependencies: Option<std::sync::Arc<spikard_core::di::ResolvedDependencies>>,
39
- }
40
-
41
- impl Serialize for RequestData {
42
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
43
- where
44
- S: serde::Serializer,
45
- {
46
- use serde::ser::SerializeStruct;
47
- #[cfg(feature = "di")]
48
- let field_count = 10;
49
- #[cfg(not(feature = "di"))]
50
- let field_count = 9;
51
-
52
- let mut state = serializer.serialize_struct("RequestData", field_count)?;
53
- state.serialize_field("path_params", &*self.path_params)?;
54
- state.serialize_field("query_params", &self.query_params)?;
55
- state.serialize_field("raw_query_params", &*self.raw_query_params)?;
56
- state.serialize_field("body", &self.body)?;
57
- state.serialize_field("raw_body", &self.raw_body.as_ref().map(|b| b.as_ref()))?;
58
- state.serialize_field("headers", &*self.headers)?;
59
- state.serialize_field("cookies", &*self.cookies)?;
60
- state.serialize_field("method", &self.method)?;
61
- state.serialize_field("path", &self.path)?;
62
-
63
- #[cfg(feature = "di")]
64
- {
65
- // Dependencies field is not serialized (contains Arc<dyn Any>)
66
- // We just serialize a marker indicating whether dependencies exist
67
- state.serialize_field("has_dependencies", &self.dependencies.is_some())?;
68
- }
69
-
70
- state.end()
71
- }
72
- }
73
-
74
- impl<'de> Deserialize<'de> for RequestData {
75
- fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
76
- where
77
- D: serde::Deserializer<'de>,
78
- {
79
- #[derive(Deserialize)]
80
- #[serde(field_identifier, rename_all = "snake_case")]
81
- enum Field {
82
- PathParams,
83
- QueryParams,
84
- RawQueryParams,
85
- Body,
86
- RawBody,
87
- Headers,
88
- Cookies,
89
- Method,
90
- Path,
91
- #[cfg(feature = "di")]
92
- HasDependencies,
93
- }
94
-
95
- struct RequestDataVisitor;
96
-
97
- impl<'de> serde::de::Visitor<'de> for RequestDataVisitor {
98
- type Value = RequestData;
99
-
100
- fn expecting(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
101
- formatter.write_str("struct RequestData")
102
- }
103
-
104
- fn visit_map<V>(self, mut map: V) -> Result<RequestData, V::Error>
105
- where
106
- V: serde::de::MapAccess<'de>,
107
- {
108
- let mut path_params = None;
109
- let mut query_params = None;
110
- let mut raw_query_params = None;
111
- let mut body = None;
112
- let mut raw_body = None;
113
- let mut headers = None;
114
- let mut cookies = None;
115
- let mut method = None;
116
- let mut path = None;
117
-
118
- while let Some(key) = map.next_key()? {
119
- match key {
120
- Field::PathParams => {
121
- path_params = Some(std::sync::Arc::new(map.next_value()?));
122
- }
123
- Field::QueryParams => {
124
- query_params = Some(map.next_value()?);
125
- }
126
- Field::RawQueryParams => {
127
- raw_query_params = Some(std::sync::Arc::new(map.next_value()?));
128
- }
129
- Field::Body => {
130
- body = Some(map.next_value()?);
131
- }
132
- Field::RawBody => {
133
- let bytes_vec: Option<Vec<u8>> = map.next_value()?;
134
- raw_body = bytes_vec.map(bytes::Bytes::from);
135
- }
136
- Field::Headers => {
137
- headers = Some(std::sync::Arc::new(map.next_value()?));
138
- }
139
- Field::Cookies => {
140
- cookies = Some(std::sync::Arc::new(map.next_value()?));
141
- }
142
- Field::Method => {
143
- method = Some(map.next_value()?);
144
- }
145
- Field::Path => {
146
- path = Some(map.next_value()?);
147
- }
148
- #[cfg(feature = "di")]
149
- Field::HasDependencies => {
150
- // We skip this field as dependencies can't be deserialized
151
- let _: bool = map.next_value()?;
152
- }
153
- }
154
- }
155
-
156
- Ok(RequestData {
157
- path_params: path_params.ok_or_else(|| serde::de::Error::missing_field("path_params"))?,
158
- query_params: query_params.ok_or_else(|| serde::de::Error::missing_field("query_params"))?,
159
- raw_query_params: raw_query_params
160
- .ok_or_else(|| serde::de::Error::missing_field("raw_query_params"))?,
161
- body: body.ok_or_else(|| serde::de::Error::missing_field("body"))?,
162
- raw_body,
163
- headers: headers.ok_or_else(|| serde::de::Error::missing_field("headers"))?,
164
- cookies: cookies.ok_or_else(|| serde::de::Error::missing_field("cookies"))?,
165
- method: method.ok_or_else(|| serde::de::Error::missing_field("method"))?,
166
- path: path.ok_or_else(|| serde::de::Error::missing_field("path"))?,
167
- #[cfg(feature = "di")]
168
- dependencies: None,
169
- })
170
- }
171
- }
172
-
173
- #[cfg(feature = "di")]
174
- const FIELDS: &[&str] = &[
175
- "path_params",
176
- "query_params",
177
- "raw_query_params",
178
- "body",
179
- "raw_body",
180
- "headers",
181
- "cookies",
182
- "method",
183
- "path",
184
- "has_dependencies",
185
- ];
186
-
187
- #[cfg(not(feature = "di"))]
188
- const FIELDS: &[&str] = &[
189
- "path_params",
190
- "query_params",
191
- "raw_query_params",
192
- "body",
193
- "raw_body",
194
- "headers",
195
- "cookies",
196
- "method",
197
- "path",
198
- ];
199
-
200
- deserializer.deserialize_struct("RequestData", FIELDS, RequestDataVisitor)
201
- }
202
- }
203
-
204
- /// Result type for handlers
205
- pub type HandlerResult = Result<Response<Body>, (StatusCode, String)>;
206
-
207
- /// Handler trait that all language bindings must implement
208
- ///
209
- /// This trait is completely language-agnostic. Each binding (Python, Node, WASM)
210
- /// implements this trait to bridge their runtime to our HTTP server.
211
- pub trait Handler: Send + Sync {
212
- /// Handle an HTTP request
213
- ///
214
- /// Takes the extracted request data and returns a future that resolves to either:
215
- /// - Ok(Response): A successful HTTP response
216
- /// - Err((StatusCode, String)): An error with status code and message
217
- fn call(
218
- &self,
219
- request: Request<Body>,
220
- request_data: RequestData,
221
- ) -> Pin<Box<dyn Future<Output = HandlerResult> + Send + '_>>;
222
- }
223
-
224
- /// Validated parameters from request (path, query, headers, cookies)
225
- #[derive(Debug, Clone)]
226
- pub struct ValidatedParams {
227
- pub params: HashMap<String, Value>,
228
- }
@@ -1,284 +0,0 @@
1
- //! Unit tests for the Handler trait and related functionality
2
- //!
3
- //! These tests verify the Handler trait works correctly and can be implemented
4
- //! by different language bindings without requiring PyO3 or other FFI dependencies.
5
-
6
- #[cfg(test)]
7
- mod tests {
8
- use crate::handler_trait::{Handler, HandlerResult, RequestData};
9
- use axum::body::Body;
10
- use axum::http::{Method, Request, Response, StatusCode};
11
- use serde_json::{Value, json};
12
- use std::collections::HashMap;
13
- use std::future::Future;
14
- use std::pin::Pin;
15
- use std::sync::Arc;
16
-
17
- /// Mock handler for testing - always returns 200 OK with echoed request data
18
- struct EchoHandler;
19
-
20
- impl Handler for EchoHandler {
21
- fn call(
22
- &self,
23
- _request: Request<Body>,
24
- request_data: RequestData,
25
- ) -> Pin<Box<dyn Future<Output = HandlerResult> + Send + '_>> {
26
- Box::pin(async move {
27
- let response_body = json!({
28
- "path_params": &*request_data.path_params,
29
- "query_params": request_data.query_params,
30
- "body": request_data.body,
31
- "headers_count": request_data.headers.len(),
32
- "cookies_count": request_data.cookies.len(),
33
- "method": request_data.method,
34
- "path": request_data.path,
35
- });
36
-
37
- let response = Response::builder()
38
- .status(StatusCode::OK)
39
- .header("Content-Type", "application/json")
40
- .body(Body::from(serde_json::to_string(&response_body).unwrap()))
41
- .unwrap();
42
-
43
- Ok(response)
44
- })
45
- }
46
- }
47
-
48
- /// Mock handler for testing - always returns errors
49
- struct ErrorHandler;
50
-
51
- impl Handler for ErrorHandler {
52
- fn call(
53
- &self,
54
- _request: Request<Body>,
55
- _request_data: RequestData,
56
- ) -> Pin<Box<dyn Future<Output = HandlerResult> + Send + '_>> {
57
- Box::pin(async move { Err((StatusCode::INTERNAL_SERVER_ERROR, "Handler error".to_string())) })
58
- }
59
- }
60
-
61
- /// Mock handler that checks for specific query parameters
62
- struct QueryParamHandler {
63
- required_param: String,
64
- }
65
-
66
- impl Handler for QueryParamHandler {
67
- fn call(
68
- &self,
69
- _request: Request<Body>,
70
- request_data: RequestData,
71
- ) -> Pin<Box<dyn Future<Output = HandlerResult> + Send + '_>> {
72
- let required = self.required_param.clone();
73
- Box::pin(async move {
74
- if request_data.raw_query_params.contains_key(&required) {
75
- let response = Response::builder()
76
- .status(StatusCode::OK)
77
- .body(Body::from("OK"))
78
- .unwrap();
79
- Ok(response)
80
- } else {
81
- Err((
82
- StatusCode::BAD_REQUEST,
83
- format!("Missing required parameter: {}", required),
84
- ))
85
- }
86
- })
87
- }
88
- }
89
-
90
- #[tokio::test]
91
- async fn test_handler_trait_echo() {
92
- let handler = Arc::new(EchoHandler);
93
-
94
- let mut path_params = HashMap::new();
95
- path_params.insert("id".to_string(), "123".to_string());
96
-
97
- let mut headers = HashMap::new();
98
- headers.insert("content-type".to_string(), "application/json".to_string());
99
-
100
- let request_data = RequestData {
101
- path_params: Arc::new(path_params),
102
- query_params: json!({"page": 1}),
103
- raw_query_params: Arc::new(HashMap::new()),
104
- body: json!({"test": "data"}),
105
- raw_body: None,
106
- headers: Arc::new(headers),
107
- cookies: Arc::new(HashMap::new()),
108
- method: "POST".to_string(),
109
- path: "/items/123".to_string(),
110
- #[cfg(feature = "di")]
111
- dependencies: None,
112
- };
113
-
114
- let request = Request::builder()
115
- .method(Method::POST)
116
- .uri("/items/123")
117
- .body(Body::empty())
118
- .unwrap();
119
-
120
- let result = handler.call(request, request_data).await;
121
- assert!(result.is_ok());
122
-
123
- let response = result.unwrap();
124
- assert_eq!(response.status(), StatusCode::OK);
125
- }
126
-
127
- #[tokio::test]
128
- async fn test_handler_trait_error() {
129
- let handler = Arc::new(ErrorHandler);
130
-
131
- let request_data = RequestData {
132
- path_params: Arc::new(HashMap::new()),
133
- query_params: Value::Null,
134
- raw_query_params: Arc::new(HashMap::new()),
135
- body: Value::Null,
136
- raw_body: None,
137
- headers: Arc::new(HashMap::new()),
138
- cookies: Arc::new(HashMap::new()),
139
- method: "GET".to_string(),
140
- path: "/error".to_string(),
141
-
142
- #[cfg(feature = "di")]
143
- dependencies: None,
144
- };
145
-
146
- let request = Request::builder()
147
- .method(Method::GET)
148
- .uri("/error")
149
- .body(Body::empty())
150
- .unwrap();
151
-
152
- let result = handler.call(request, request_data).await;
153
- assert!(result.is_err());
154
-
155
- let (status, message) = result.unwrap_err();
156
- assert_eq!(status, StatusCode::INTERNAL_SERVER_ERROR);
157
- assert_eq!(message, "Handler error");
158
- }
159
-
160
- #[tokio::test]
161
- async fn test_handler_trait_query_params() {
162
- let handler = Arc::new(QueryParamHandler {
163
- required_param: "api_key".to_string(),
164
- });
165
-
166
- let mut raw_query_params = HashMap::new();
167
- raw_query_params.insert("api_key".to_string(), vec!["secret123".to_string()]);
168
-
169
- let request_data = RequestData {
170
- path_params: Arc::new(HashMap::new()),
171
- query_params: json!({"api_key": "secret123"}),
172
- raw_query_params: Arc::new(raw_query_params.clone()),
173
- body: Value::Null,
174
- raw_body: None,
175
- headers: Arc::new(HashMap::new()),
176
- cookies: Arc::new(HashMap::new()),
177
- method: "GET".to_string(),
178
- path: "/api/data".to_string(),
179
- #[cfg(feature = "di")]
180
- dependencies: None,
181
- };
182
-
183
- let request = Request::builder()
184
- .method(Method::GET)
185
- .uri("/api/data?api_key=secret123")
186
- .body(Body::empty())
187
- .unwrap();
188
-
189
- let result = handler.call(request, request_data).await;
190
- assert!(result.is_ok());
191
-
192
- let request_data_no_param = RequestData {
193
- path_params: Arc::new(HashMap::new()),
194
- query_params: Value::Null,
195
- raw_query_params: Arc::new(HashMap::new()),
196
- body: Value::Null,
197
- raw_body: None,
198
- headers: Arc::new(HashMap::new()),
199
- cookies: Arc::new(HashMap::new()),
200
- method: "GET".to_string(),
201
- path: "/api/data".to_string(),
202
-
203
- #[cfg(feature = "di")]
204
- dependencies: None,
205
- };
206
-
207
- let request_no_param = Request::builder()
208
- .method(Method::GET)
209
- .uri("/api/data")
210
- .body(Body::empty())
211
- .unwrap();
212
-
213
- let result_err = handler.call(request_no_param, request_data_no_param).await;
214
- assert!(result_err.is_err());
215
-
216
- let (status, message) = result_err.unwrap_err();
217
- assert_eq!(status, StatusCode::BAD_REQUEST);
218
- assert!(message.contains("api_key"));
219
- }
220
-
221
- #[tokio::test]
222
- async fn test_request_data_serialization() {
223
- let mut path_params = HashMap::new();
224
- path_params.insert("user_id".to_string(), "42".to_string());
225
-
226
- let mut raw_query_params = HashMap::new();
227
- raw_query_params.insert("filter".to_string(), vec!["active".to_string()]);
228
-
229
- let request_data = RequestData {
230
- path_params: Arc::new(path_params),
231
- query_params: json!({"filter": "active"}),
232
- raw_query_params: Arc::new(raw_query_params),
233
- body: json!({"name": "test"}),
234
- raw_body: None,
235
- headers: Arc::new(HashMap::new()),
236
- cookies: Arc::new(HashMap::new()),
237
- method: "PUT".to_string(),
238
- path: "/users/42".to_string(),
239
- #[cfg(feature = "di")]
240
- dependencies: None,
241
- };
242
-
243
- let json_str = serde_json::to_string(&request_data).unwrap();
244
- let deserialized: RequestData = serde_json::from_str(&json_str).unwrap();
245
-
246
- assert_eq!(deserialized.method, "PUT");
247
- assert_eq!(deserialized.path, "/users/42");
248
- assert_eq!(deserialized.path_params.get("user_id").unwrap(), "42");
249
- assert_eq!(deserialized.body, json!({"name": "test"}));
250
- }
251
-
252
- #[test]
253
- fn test_request_data_default_values() {
254
- let request_data = RequestData {
255
- path_params: Arc::new(HashMap::new()),
256
- query_params: Value::Null,
257
- raw_query_params: Arc::new(HashMap::new()),
258
- body: Value::Null,
259
- raw_body: None,
260
- headers: Arc::new(HashMap::new()),
261
- cookies: Arc::new(HashMap::new()),
262
- method: "GET".to_string(),
263
- path: "/".to_string(),
264
-
265
- #[cfg(feature = "di")]
266
- dependencies: None,
267
- };
268
-
269
- assert_eq!(request_data.method, "GET");
270
- assert_eq!(request_data.path, "/");
271
- assert!(request_data.path_params.is_empty());
272
- assert!(request_data.raw_query_params.is_empty());
273
- assert!(request_data.headers.is_empty());
274
- assert!(request_data.cookies.is_empty());
275
- assert_eq!(request_data.body, Value::Null);
276
- assert_eq!(request_data.query_params, Value::Null);
277
- }
278
-
279
- #[test]
280
- fn test_handler_is_send_sync() {
281
- fn assert_send_sync<T: Send + Sync>() {}
282
- assert_send_sync::<Arc<dyn Handler>>();
283
- }
284
- }