pub struct SetTraceIdLayer<T>where
T: MakeTraceId,{ /* private fields */ }Expand description
Add the TraceId
use std::convert::Infallible;
use hyper::{Body, Request, Response};
use tower::ServiceBuilder;
use hyper_trace_id::{SetTraceIdLayer, TraceId};
let trace_id_header = "x-trace-id";
let svc = ServiceBuilder::new()
.layer(SetTraceIdLayer::<String>::new().with_header_name(trace_id_header))
.service_fn(|_req: Request<Body>| async {
let res: Result<Response<Body>, Infallible> = Ok(Response::new(Body::empty()));
res
});
Implementations§
Source§impl<T> SetTraceIdLayer<T>where
T: MakeTraceId,
impl<T> SetTraceIdLayer<T>where
T: MakeTraceId,
pub fn new() -> Self
pub fn with_header_name(self, header_name: &str) -> Self
Trait Implementations§
Source§impl<T> Clone for SetTraceIdLayer<T>where
T: MakeTraceId + Clone,
impl<T> Clone for SetTraceIdLayer<T>where
T: MakeTraceId + Clone,
Source§fn clone(&self) -> SetTraceIdLayer<T>
fn clone(&self) -> SetTraceIdLayer<T>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<T> Debug for SetTraceIdLayer<T>where
T: MakeTraceId + Debug,
impl<T> Debug for SetTraceIdLayer<T>where
T: MakeTraceId + Debug,
Source§impl<T> Default for SetTraceIdLayer<T>where
T: MakeTraceId,
impl<T> Default for SetTraceIdLayer<T>where
T: MakeTraceId,
Auto Trait Implementations§
impl<T> !Freeze for SetTraceIdLayer<T>
impl<T> RefUnwindSafe for SetTraceIdLayer<T>where
T: RefUnwindSafe,
impl<T> Send for SetTraceIdLayer<T>
impl<T> Sync for SetTraceIdLayer<T>
impl<T> Unpin for SetTraceIdLayer<T>where
T: Unpin,
impl<T> UnwindSafe for SetTraceIdLayer<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more