spikard 0.8.1 → 0.8.2

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 (27) hide show
  1. checksums.yaml +4 -4
  2. data/ext/spikard_rb/Cargo.toml +1 -1
  3. data/lib/spikard/grpc.rb +5 -5
  4. data/lib/spikard/version.rb +1 -1
  5. data/vendor/crates/spikard-bindings-shared/Cargo.toml +1 -1
  6. data/vendor/crates/spikard-bindings-shared/src/grpc_metadata.rs +3 -3
  7. data/vendor/crates/spikard-core/Cargo.toml +1 -1
  8. data/vendor/crates/spikard-core/src/metadata.rs +3 -14
  9. data/vendor/crates/spikard-http/Cargo.toml +1 -1
  10. data/vendor/crates/spikard-http/src/grpc/mod.rs +1 -1
  11. data/vendor/crates/spikard-http/src/grpc/service.rs +11 -11
  12. data/vendor/crates/spikard-http/src/grpc/streaming.rs +5 -1
  13. data/vendor/crates/spikard-http/src/server/grpc_routing.rs +59 -20
  14. data/vendor/crates/spikard-http/src/server/routing_factory.rs +179 -201
  15. data/vendor/crates/spikard-http/tests/common/grpc_helpers.rs +49 -60
  16. data/vendor/crates/spikard-http/tests/common/handlers.rs +5 -5
  17. data/vendor/crates/spikard-http/tests/common/mod.rs +7 -8
  18. data/vendor/crates/spikard-http/tests/common/test_builders.rs +14 -19
  19. data/vendor/crates/spikard-http/tests/grpc_error_handling_test.rs +68 -69
  20. data/vendor/crates/spikard-http/tests/grpc_integration_test.rs +1 -3
  21. data/vendor/crates/spikard-http/tests/grpc_metadata_test.rs +98 -84
  22. data/vendor/crates/spikard-http/tests/grpc_server_integration.rs +76 -57
  23. data/vendor/crates/spikard-rb/Cargo.toml +1 -1
  24. data/vendor/crates/spikard-rb/src/grpc/handler.rs +30 -25
  25. data/vendor/crates/spikard-rb/src/lib.rs +1 -2
  26. data/vendor/crates/spikard-rb-macros/Cargo.toml +1 -1
  27. metadata +1 -1
@@ -145,98 +145,89 @@ impl MethodRouterFactory {
145
145
  HttpMethod::Post => {
146
146
  let handler_clone = handler_clone.clone();
147
147
  let hooks_clone = hooks_clone.clone();
148
- axum::routing::post(
149
- move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
150
- let handler = handler_clone.clone();
151
- let hooks = hooks_clone.clone();
152
- async move {
153
- let (parts, body) = req.into_parts();
154
- let request_data =
155
- request_extraction::create_request_data_with_body(
156
- &parts,
157
- path_params.0,
158
- body,
159
- include_raw_query_params,
160
- include_query_params_json,
161
- include_headers,
162
- include_cookies,
163
- )
164
- .await?;
165
- let mut req = Request::from_parts(
166
- parts,
167
- Body::from(request_data.raw_body.clone().unwrap_or_else(Bytes::new)),
168
- );
169
- if handler.wants_request_extensions() {
148
+ axum::routing::post(move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
149
+ let handler = handler_clone.clone();
150
+ let hooks = hooks_clone.clone();
151
+ async move {
152
+ let (parts, body) = req.into_parts();
153
+ let request_data = request_extraction::create_request_data_with_body(
154
+ &parts,
155
+ path_params.0,
156
+ body,
157
+ include_raw_query_params,
158
+ include_query_params_json,
159
+ include_headers,
160
+ include_cookies,
161
+ )
162
+ .await?;
163
+ let mut req = Request::from_parts(
164
+ parts,
165
+ Body::from(request_data.raw_body.clone().unwrap_or_else(Bytes::new)),
166
+ );
167
+ if handler.wants_request_extensions() {
170
168
  req.extensions_mut().insert(Arc::new(request_data.clone()));
171
169
  }
172
- call_with_optional_hooks(req, request_data, handler, hooks).await
173
- }
174
- },
175
- )
170
+ call_with_optional_hooks(req, request_data, handler, hooks).await
171
+ }
172
+ })
176
173
  }
177
174
  HttpMethod::Put => {
178
175
  let handler_clone = handler_clone.clone();
179
176
  let hooks_clone = hooks_clone.clone();
180
- axum::routing::put(
181
- move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
182
- let handler = handler_clone.clone();
183
- let hooks = hooks_clone.clone();
184
- async move {
185
- let (parts, body) = req.into_parts();
186
- let request_data =
187
- request_extraction::create_request_data_with_body(
188
- &parts,
189
- path_params.0,
190
- body,
191
- include_raw_query_params,
192
- include_query_params_json,
193
- include_headers,
194
- include_cookies,
195
- )
196
- .await?;
197
- let mut req = Request::from_parts(
198
- parts,
199
- Body::from(request_data.raw_body.clone().unwrap_or_else(Bytes::new)),
200
- );
201
- if handler.wants_request_extensions() {
177
+ axum::routing::put(move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
178
+ let handler = handler_clone.clone();
179
+ let hooks = hooks_clone.clone();
180
+ async move {
181
+ let (parts, body) = req.into_parts();
182
+ let request_data = request_extraction::create_request_data_with_body(
183
+ &parts,
184
+ path_params.0,
185
+ body,
186
+ include_raw_query_params,
187
+ include_query_params_json,
188
+ include_headers,
189
+ include_cookies,
190
+ )
191
+ .await?;
192
+ let mut req = Request::from_parts(
193
+ parts,
194
+ Body::from(request_data.raw_body.clone().unwrap_or_else(Bytes::new)),
195
+ );
196
+ if handler.wants_request_extensions() {
202
197
  req.extensions_mut().insert(Arc::new(request_data.clone()));
203
198
  }
204
- call_with_optional_hooks(req, request_data, handler, hooks).await
205
- }
206
- },
207
- )
199
+ call_with_optional_hooks(req, request_data, handler, hooks).await
200
+ }
201
+ })
208
202
  }
209
203
  HttpMethod::Patch => {
210
204
  let handler_clone = handler_clone.clone();
211
205
  let hooks_clone = hooks_clone.clone();
212
- axum::routing::patch(
213
- move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
214
- let handler = handler_clone.clone();
215
- let hooks = hooks_clone.clone();
216
- async move {
217
- let (parts, body) = req.into_parts();
218
- let request_data =
219
- request_extraction::create_request_data_with_body(
220
- &parts,
221
- path_params.0,
222
- body,
223
- include_raw_query_params,
224
- include_query_params_json,
225
- include_headers,
226
- include_cookies,
227
- )
228
- .await?;
229
- let mut req = Request::from_parts(
230
- parts,
231
- Body::from(request_data.raw_body.clone().unwrap_or_else(Bytes::new)),
232
- );
233
- if handler.wants_request_extensions() {
206
+ axum::routing::patch(move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
207
+ let handler = handler_clone.clone();
208
+ let hooks = hooks_clone.clone();
209
+ async move {
210
+ let (parts, body) = req.into_parts();
211
+ let request_data = request_extraction::create_request_data_with_body(
212
+ &parts,
213
+ path_params.0,
214
+ body,
215
+ include_raw_query_params,
216
+ include_query_params_json,
217
+ include_headers,
218
+ include_cookies,
219
+ )
220
+ .await?;
221
+ let mut req = Request::from_parts(
222
+ parts,
223
+ Body::from(request_data.raw_body.clone().unwrap_or_else(Bytes::new)),
224
+ );
225
+ if handler.wants_request_extensions() {
234
226
  req.extensions_mut().insert(Arc::new(request_data.clone()));
235
227
  }
236
- call_with_optional_hooks(req, request_data, handler, hooks).await
237
- }
238
- },
239
- )
228
+ call_with_optional_hooks(req, request_data, handler, hooks).await
229
+ }
230
+ })
240
231
  }
241
232
  _ => MethodRouter::new(),
242
233
  }
@@ -245,122 +236,112 @@ impl MethodRouterFactory {
245
236
  HttpMethod::Get => {
246
237
  let handler_clone = handler_clone.clone();
247
238
  let hooks_clone = hooks_clone.clone();
248
- axum::routing::get(
249
- move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
250
- let handler = handler_clone.clone();
251
- let hooks = hooks_clone.clone();
252
- async move {
253
- let request_data = request_extraction::create_request_data_without_body(
254
- req.uri(),
255
- req.method(),
256
- req.headers(),
257
- path_params.0,
258
- without_body_options,
259
- );
260
- let mut req = req;
261
- if handler.wants_request_extensions() {
239
+ axum::routing::get(move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
240
+ let handler = handler_clone.clone();
241
+ let hooks = hooks_clone.clone();
242
+ async move {
243
+ let request_data = request_extraction::create_request_data_without_body(
244
+ req.uri(),
245
+ req.method(),
246
+ req.headers(),
247
+ path_params.0,
248
+ without_body_options,
249
+ );
250
+ let mut req = req;
251
+ if handler.wants_request_extensions() {
262
252
  req.extensions_mut().insert(Arc::new(request_data.clone()));
263
253
  }
264
- call_with_optional_hooks(req, request_data, handler, hooks).await
265
- }
266
- },
267
- )
254
+ call_with_optional_hooks(req, request_data, handler, hooks).await
255
+ }
256
+ })
268
257
  }
269
258
  HttpMethod::Delete => {
270
259
  let handler_clone = handler_clone.clone();
271
260
  let hooks_clone = hooks_clone.clone();
272
- axum::routing::delete(
273
- move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
274
- let handler = handler_clone.clone();
275
- let hooks = hooks_clone.clone();
276
- async move {
277
- let request_data = request_extraction::create_request_data_without_body(
278
- req.uri(),
279
- req.method(),
280
- req.headers(),
281
- path_params.0,
282
- without_body_options,
283
- );
284
- let mut req = req;
285
- if handler.wants_request_extensions() {
261
+ axum::routing::delete(move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
262
+ let handler = handler_clone.clone();
263
+ let hooks = hooks_clone.clone();
264
+ async move {
265
+ let request_data = request_extraction::create_request_data_without_body(
266
+ req.uri(),
267
+ req.method(),
268
+ req.headers(),
269
+ path_params.0,
270
+ without_body_options,
271
+ );
272
+ let mut req = req;
273
+ if handler.wants_request_extensions() {
286
274
  req.extensions_mut().insert(Arc::new(request_data.clone()));
287
275
  }
288
- call_with_optional_hooks(req, request_data, handler, hooks).await
289
- }
290
- },
291
- )
276
+ call_with_optional_hooks(req, request_data, handler, hooks).await
277
+ }
278
+ })
292
279
  }
293
280
  HttpMethod::Head => {
294
281
  let handler_clone = handler_clone.clone();
295
282
  let hooks_clone = hooks_clone.clone();
296
- axum::routing::head(
297
- move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
298
- let handler = handler_clone.clone();
299
- let hooks = hooks_clone.clone();
300
- async move {
301
- let request_data = request_extraction::create_request_data_without_body(
302
- req.uri(),
303
- req.method(),
304
- req.headers(),
305
- path_params.0,
306
- without_body_options,
307
- );
308
- let mut req = req;
309
- if handler.wants_request_extensions() {
283
+ axum::routing::head(move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
284
+ let handler = handler_clone.clone();
285
+ let hooks = hooks_clone.clone();
286
+ async move {
287
+ let request_data = request_extraction::create_request_data_without_body(
288
+ req.uri(),
289
+ req.method(),
290
+ req.headers(),
291
+ path_params.0,
292
+ without_body_options,
293
+ );
294
+ let mut req = req;
295
+ if handler.wants_request_extensions() {
310
296
  req.extensions_mut().insert(Arc::new(request_data.clone()));
311
297
  }
312
- call_with_optional_hooks(req, request_data, handler, hooks).await
313
- }
314
- },
315
- )
298
+ call_with_optional_hooks(req, request_data, handler, hooks).await
299
+ }
300
+ })
316
301
  }
317
302
  HttpMethod::Trace => {
318
303
  let handler_clone = handler_clone.clone();
319
304
  let hooks_clone = hooks_clone.clone();
320
- axum::routing::trace(
321
- move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
322
- let handler = handler_clone.clone();
323
- let hooks = hooks_clone.clone();
324
- async move {
325
- let request_data = request_extraction::create_request_data_without_body(
326
- req.uri(),
327
- req.method(),
328
- req.headers(),
329
- path_params.0,
330
- without_body_options,
331
- );
332
- let mut req = req;
333
- if handler.wants_request_extensions() {
305
+ axum::routing::trace(move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
306
+ let handler = handler_clone.clone();
307
+ let hooks = hooks_clone.clone();
308
+ async move {
309
+ let request_data = request_extraction::create_request_data_without_body(
310
+ req.uri(),
311
+ req.method(),
312
+ req.headers(),
313
+ path_params.0,
314
+ without_body_options,
315
+ );
316
+ let mut req = req;
317
+ if handler.wants_request_extensions() {
334
318
  req.extensions_mut().insert(Arc::new(request_data.clone()));
335
319
  }
336
- call_with_optional_hooks(req, request_data, handler, hooks).await
337
- }
338
- },
339
- )
320
+ call_with_optional_hooks(req, request_data, handler, hooks).await
321
+ }
322
+ })
340
323
  }
341
324
  HttpMethod::Options => {
342
325
  let handler_clone = handler_clone.clone();
343
326
  let hooks_clone = hooks_clone.clone();
344
- axum::routing::options(
345
- move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
346
- let handler = handler_clone.clone();
347
- let hooks = hooks_clone.clone();
348
- async move {
349
- let request_data = request_extraction::create_request_data_without_body(
350
- req.uri(),
351
- req.method(),
352
- req.headers(),
353
- path_params.0,
354
- without_body_options,
355
- );
356
- let mut req = req;
357
- if handler.wants_request_extensions() {
327
+ axum::routing::options(move |path_params: Path<HashMap<String, String>>, req: AxumRequest| {
328
+ let handler = handler_clone.clone();
329
+ let hooks = hooks_clone.clone();
330
+ async move {
331
+ let request_data = request_extraction::create_request_data_without_body(
332
+ req.uri(),
333
+ req.method(),
334
+ req.headers(),
335
+ path_params.0,
336
+ without_body_options,
337
+ );
338
+ let mut req = req;
339
+ if handler.wants_request_extensions() {
358
340
  req.extensions_mut().insert(Arc::new(request_data.clone()));
359
341
  }
360
- call_with_optional_hooks(req, request_data, handler, hooks).await
361
- }
362
- },
363
- )
342
+ call_with_optional_hooks(req, request_data, handler, hooks).await
343
+ }
344
+ })
364
345
  }
365
346
  _ => MethodRouter::new(),
366
347
  }
@@ -396,17 +377,16 @@ impl MethodRouterFactory {
396
377
  let hooks = hooks_clone.clone();
397
378
  async move {
398
379
  let (parts, body) = req.into_parts();
399
- let request_data =
400
- request_extraction::create_request_data_with_body(
401
- &parts,
402
- HashMap::new(),
403
- body,
404
- include_raw_query_params,
405
- include_query_params_json,
406
- include_headers,
407
- include_cookies,
408
- )
409
- .await?;
380
+ let request_data = request_extraction::create_request_data_with_body(
381
+ &parts,
382
+ HashMap::new(),
383
+ body,
384
+ include_raw_query_params,
385
+ include_query_params_json,
386
+ include_headers,
387
+ include_cookies,
388
+ )
389
+ .await?;
410
390
  let mut req = Request::from_parts(
411
391
  parts,
412
392
  Body::from(request_data.raw_body.clone().unwrap_or_else(Bytes::new)),
@@ -426,17 +406,16 @@ impl MethodRouterFactory {
426
406
  let hooks = hooks_clone.clone();
427
407
  async move {
428
408
  let (parts, body) = req.into_parts();
429
- let request_data =
430
- request_extraction::create_request_data_with_body(
431
- &parts,
432
- HashMap::new(),
433
- body,
434
- include_raw_query_params,
435
- include_query_params_json,
436
- include_headers,
437
- include_cookies,
438
- )
439
- .await?;
409
+ let request_data = request_extraction::create_request_data_with_body(
410
+ &parts,
411
+ HashMap::new(),
412
+ body,
413
+ include_raw_query_params,
414
+ include_query_params_json,
415
+ include_headers,
416
+ include_cookies,
417
+ )
418
+ .await?;
440
419
  let mut req = Request::from_parts(
441
420
  parts,
442
421
  Body::from(request_data.raw_body.clone().unwrap_or_else(Bytes::new)),
@@ -456,17 +435,16 @@ impl MethodRouterFactory {
456
435
  let hooks = hooks_clone.clone();
457
436
  async move {
458
437
  let (parts, body) = req.into_parts();
459
- let request_data =
460
- request_extraction::create_request_data_with_body(
461
- &parts,
462
- HashMap::new(),
463
- body,
464
- include_raw_query_params,
465
- include_query_params_json,
466
- include_headers,
467
- include_cookies,
468
- )
469
- .await?;
438
+ let request_data = request_extraction::create_request_data_with_body(
439
+ &parts,
440
+ HashMap::new(),
441
+ body,
442
+ include_raw_query_params,
443
+ include_query_params_json,
444
+ include_headers,
445
+ include_cookies,
446
+ )
447
+ .await?;
470
448
  let mut req = Request::from_parts(
471
449
  parts,
472
450
  Body::from(request_data.raw_body.clone().unwrap_or_else(Bytes::new)),