@@ -204,6 +204,7 @@ use hyperlane::*;
204
204
use hyperlane_macros :: * ;
205
205
use serde :: {Deserialize , Serialize };
206
206
207
+ const STEP : & str = " step" ;
207
208
const TEST_ATTRIBUTE_KEY : & str = " test_attribute_key" ;
208
209
const CUSTOM_STATUS_CODE : i32 = 200 ;
209
210
const CUSTOM_REASON : & str = " Accepted" ;
@@ -217,29 +218,11 @@ struct TestData {
217
218
age : u32 ,
218
219
}
219
220
220
- #[response_body(" 1" )]
221
- #[request_middleware]
222
- #[response_version(HttpVersion :: HTTP1_1 )]
223
- async fn request_middleware (ctx : Context ) {}
224
-
225
- #[response_body(" 2" )]
226
- #[request_middleware(1)]
227
- #[response_version(HttpVersion :: HTTP1_1 )]
228
- async fn request_middleware_1 (ctx : Context ) {}
229
-
230
- #[response_middleware]
231
- async fn response_middleware (ctx : Context ) {
232
- if ctx . get_request (). await . get_upgrade_type (). is_ws () {
233
- return ;
234
- }
235
- }
236
-
237
221
#[send]
238
- #[response_middleware(1)]
239
- async fn response_middleware_1 (ctx : Context ) {}
240
-
241
222
#[panic_hook]
242
- #[send]
223
+ #[panic_hook(1)]
224
+ #[panic_hook(" 2" )]
225
+ #[response_body(" panic_hook" )]
243
226
async fn panic_hook (ctx : Context ) {}
244
227
245
228
#[route(" /disable_http_hook" )]
@@ -252,13 +235,56 @@ async fn disable_http_hook(ctx: Context) {}
252
235
#[disable_ws_hook(" /disable_ws_hook" )]
253
236
async fn disable_ws_hook (ctx : Context ) {}
254
237
238
+ #[connected_hook]
239
+ #[connected_hook(1)]
240
+ #[connected_hook(" 2" )]
241
+ #[response_header(STEP => " connected_hook" )]
242
+ async fn connected_hook (ctx : Context ) {}
243
+
244
+ #[pre_upgrade_hook]
245
+ #[pre_upgrade_hook(1)]
246
+ #[pre_upgrade_hook(" 2" )]
247
+ #[response_header(STEP => " pre_upgrade_hook" )]
248
+ async fn pre_upgrade_hook (ctx : Context ) {}
249
+
250
+ #[request_middleware]
251
+ #[response_header(SERVER => HYPERLANE )]
252
+ #[response_version(HttpVersion :: HTTP1_1 )]
253
+ #[response_header(STEP => " request_middleware_1" )]
254
+ async fn request_middleware_1 (ctx : Context ) {}
255
+
256
+ #[request_middleware(2)]
257
+ #[response_header(STEP => " request_middleware_2" )]
258
+ async fn request_middleware_2 (ctx : Context ) {}
259
+
260
+ #[request_middleware(" 3" )]
261
+ #[response_header(STEP => " request_middleware_3" )]
262
+ async fn request_middleware_3 (ctx : Context ) {}
263
+
264
+ #[response_middleware]
265
+ #[response_header(STEP => " response_middleware_1" )]
266
+ async fn response_middleware_1 (ctx : Context ) {}
267
+
268
+ #[response_middleware(2)]
269
+ #[response_header(STEP => " response_middleware_2" )]
270
+ async fn response_middleware_2 (ctx : Context ) {}
271
+
272
+ #[send]
273
+ #[response_middleware(" 3" )]
274
+ #[response_header(STEP => " response_middleware_3" )]
275
+ async fn response_middleware_3 (ctx : Context ) {
276
+ if ctx . get_request (). await . get_upgrade_type (). is_ws () {
277
+ return ;
278
+ }
279
+ }
280
+
255
281
#[get]
256
282
#[http]
257
- async fn ctx_pre_hook (ctx : Context ) {}
283
+ async fn pre_hook (ctx : Context ) {}
258
284
259
285
#[flush]
260
286
#[response_status_code(200)]
261
- async fn ctx_post_hook (ctx : Context ) {}
287
+ async fn post_hook (ctx : Context ) {}
262
288
263
289
#[route(" /response" )]
264
290
#[response_body(RESPONSE_DATA )]
@@ -267,79 +293,79 @@ async fn ctx_post_hook(ctx: Context) {}
267
293
#[response_header(CUSTOM_HEADER_NAME => CUSTOM_HEADER_VALUE )]
268
294
async fn response (ctx : Context ) {}
269
295
270
- #[connect]
271
296
#[route(" /connect" )]
272
297
#[response_body(" connect" )]
298
+ #[connect]
273
299
async fn connect (ctx : Context ) {}
274
300
275
- #[delete]
276
301
#[route(" /delete" )]
277
302
#[response_body(" delete" )]
303
+ #[delete]
278
304
async fn delete (ctx : Context ) {}
279
305
280
- #[head]
281
306
#[route(" /head" )]
282
307
#[response_body(" head" )]
308
+ #[head]
283
309
async fn head (ctx : Context ) {}
284
310
285
- #[options]
286
311
#[route(" /options" )]
287
312
#[response_body(" options" )]
313
+ #[options]
288
314
async fn options (ctx : Context ) {}
289
315
290
- #[patch]
291
316
#[route(" /patch" )]
292
317
#[response_body(" patch" )]
318
+ #[patch]
293
319
async fn patch (ctx : Context ) {}
294
320
295
- #[put]
296
321
#[route(" /put" )]
297
322
#[response_body(" put" )]
323
+ #[put]
298
324
async fn put (ctx : Context ) {}
299
325
300
- #[trace]
301
326
#[route(" /trace" )]
302
327
#[response_body(" trace" )]
328
+ #[trace]
303
329
async fn trace (ctx : Context ) {}
304
330
305
- #[h2c]
306
331
#[route(" /h2c" )]
307
332
#[response_body(" h2c" )]
333
+ #[h2c]
308
334
async fn h2c (ctx : Context ) {}
309
335
310
- #[http]
311
336
#[route(" /http" )]
312
337
#[response_body(" http" )]
338
+ #[http]
313
339
async fn http_only (ctx : Context ) {}
314
340
315
- #[http0_9]
316
341
#[route(" /http0_9" )]
317
342
#[response_body(" http0.9" )]
343
+ #[http0_9]
318
344
async fn http0_9 (ctx : Context ) {}
319
345
320
- #[http1_0]
321
346
#[route(" /http1_0" )]
322
347
#[response_body(" http1.0" )]
348
+ #[http1_0]
323
349
async fn http1_0 (ctx : Context ) {}
324
350
325
- #[http1_1]
326
351
#[route(" /http1_1" )]
327
352
#[response_body(" http1.1" )]
353
+ #[http1_1]
328
354
async fn http1_1 (ctx : Context ) {}
329
355
330
- #[http2]
331
356
#[route(" /http2" )]
332
357
#[response_body(" http2" )]
358
+ #[http2]
333
359
async fn http2 (ctx : Context ) {}
334
360
335
- #[http3]
336
361
#[route(" /http3" )]
337
362
#[response_body(" http3" )]
363
+ #[http3]
338
364
async fn http3 (ctx : Context ) {}
339
365
340
- #[tls]
341
366
#[route(" /tls" )]
342
367
#[response_body(" tls" )]
368
+ #[tls]
343
369
async fn tls (ctx : Context ) {}
344
370
345
371
#[http1_1_or_higher]
@@ -367,38 +393,38 @@ async fn unknown_version(ctx: Context) {}
367
393
#[response_body(" unknown all" )]
368
394
async fn unknown_all (ctx : Context ) {}
369
395
370
- #[ws]
371
- #[get]
372
- #[send_body]
373
396
#[route(" /get" )]
397
+ #[send_once_body]
374
398
#[response_body(" get" )]
399
+ #[ws]
400
+ #[get]
375
401
async fn get (ctx : Context ) {}
376
402
377
- #[post]
378
403
#[send_once]
379
404
#[route(" /post" )]
380
405
#[response_body(" post" )]
406
+ #[post]
381
407
async fn post (ctx : Context ) {}
382
408
383
- #[ws]
384
- #[send_once_body]
409
+ #[send_body]
385
410
#[route(" /websocket" )]
386
411
#[response_body(" websocket" )]
412
+ #[ws]
387
413
async fn websocket (ctx : Context ) {}
388
414
389
- #[route(" /ctx_hook " )]
390
- #[pre_hook(ctx_pre_hook )]
391
- #[post_hook(ctx_post_hook )]
415
+ #[route(" /hook " )]
416
+ #[pre_hook(pre_hook )]
417
+ #[post_hook(post_hook )]
392
418
#[response_body(" Testing hook macro" )]
393
- async fn ctx_hook (ctx : Context ) {}
419
+ async fn hook (ctx : Context ) {}
394
420
395
- #[http]
396
421
#[closed]
397
422
#[route(" /get_post" )]
398
423
#[methods(get, post)]
399
424
#[response_reason_phrase(" OK" )]
400
425
#[response_status_code(200)]
401
426
#[response_body(" get_post" )]
427
+ #[http]
402
428
async fn get_post (ctx : Context ) {}
403
429
404
430
#[route(" /attributes" )]
0 commit comments