@@ -181,6 +181,7 @@ use tower_layer::Layer;
181
181
use tower_service:: Service ;
182
182
use uuid:: Uuid ;
183
183
184
+ pub ( crate ) const REQUEST_ID : HeaderName = HeaderName :: from_static ( "request-id" ) ;
184
185
pub ( crate ) const X_REQUEST_ID : HeaderName = HeaderName :: from_static ( "x-request-id" ) ;
185
186
186
187
/// Trait for producing [`RequestId`]s.
@@ -241,6 +242,14 @@ impl<M> SetRequestIdLayer<M> {
241
242
}
242
243
}
243
244
245
+ /// Create a new `SetRequestIdLayer` that uses `request-id` as the header name.
246
+ pub fn request_id ( make_request_id : M ) -> Self
247
+ where
248
+ M : MakeRequestId ,
249
+ {
250
+ SetRequestIdLayer :: new ( REQUEST_ID , make_request_id)
251
+ }
252
+
244
253
/// Create a new `SetRequestIdLayer` that uses `x-request-id` as the header name.
245
254
pub fn x_request_id ( make_request_id : M ) -> Self
246
255
where
@@ -294,6 +303,14 @@ impl<S, M> SetRequestId<S, M> {
294
303
}
295
304
}
296
305
306
+ /// Create a new `SetRequestId` that uses `request-id` as the header name.
307
+ pub fn request_id ( inner : S , make_request_id : M ) -> Self
308
+ where
309
+ M : MakeRequestId ,
310
+ {
311
+ Self :: new ( inner, REQUEST_ID , make_request_id)
312
+ }
313
+
297
314
/// Create a new `SetRequestId` that uses `x-request-id` as the header name.
298
315
pub fn x_request_id ( inner : S , make_request_id : M ) -> Self
299
316
where
@@ -359,6 +376,11 @@ impl PropagateRequestIdLayer {
359
376
PropagateRequestIdLayer { header_name }
360
377
}
361
378
379
+ /// Create a new `PropagateRequestIdLayer` that uses `request-id` as the header name.
380
+ pub fn request_id ( ) -> Self {
381
+ Self :: new ( REQUEST_ID )
382
+ }
383
+
362
384
/// Create a new `PropagateRequestIdLayer` that uses `x-request-id` as the header name.
363
385
pub fn x_request_id ( ) -> Self {
364
386
Self :: new ( X_REQUEST_ID )
0 commit comments