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.
- checksums.yaml +4 -4
- data/ext/spikard_rb/Cargo.toml +1 -1
- data/lib/spikard/grpc.rb +5 -5
- data/lib/spikard/version.rb +1 -1
- data/vendor/crates/spikard-bindings-shared/Cargo.toml +1 -1
- data/vendor/crates/spikard-bindings-shared/src/grpc_metadata.rs +3 -3
- data/vendor/crates/spikard-core/Cargo.toml +1 -1
- data/vendor/crates/spikard-core/src/metadata.rs +3 -14
- data/vendor/crates/spikard-http/Cargo.toml +1 -1
- data/vendor/crates/spikard-http/src/grpc/mod.rs +1 -1
- data/vendor/crates/spikard-http/src/grpc/service.rs +11 -11
- data/vendor/crates/spikard-http/src/grpc/streaming.rs +5 -1
- data/vendor/crates/spikard-http/src/server/grpc_routing.rs +59 -20
- data/vendor/crates/spikard-http/src/server/routing_factory.rs +179 -201
- data/vendor/crates/spikard-http/tests/common/grpc_helpers.rs +49 -60
- data/vendor/crates/spikard-http/tests/common/handlers.rs +5 -5
- data/vendor/crates/spikard-http/tests/common/mod.rs +7 -8
- data/vendor/crates/spikard-http/tests/common/test_builders.rs +14 -19
- data/vendor/crates/spikard-http/tests/grpc_error_handling_test.rs +68 -69
- data/vendor/crates/spikard-http/tests/grpc_integration_test.rs +1 -3
- data/vendor/crates/spikard-http/tests/grpc_metadata_test.rs +98 -84
- data/vendor/crates/spikard-http/tests/grpc_server_integration.rs +76 -57
- data/vendor/crates/spikard-rb/Cargo.toml +1 -1
- data/vendor/crates/spikard-rb/src/grpc/handler.rs +30 -25
- data/vendor/crates/spikard-rb/src/lib.rs +1 -2
- data/vendor/crates/spikard-rb-macros/Cargo.toml +1 -1
- 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
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
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
|
-
|
|
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
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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
|
-
|
|
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
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
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
|
-
|
|
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
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
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
|
-
|
|
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
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
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
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
|
|
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
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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
|
-
|
|
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
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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
|
-
|
|
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
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
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
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
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
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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)),
|