pub struct CommonInterceptor { /* private fields */ }Expand description
通用日志拦截器,请求完成后通过 tracing 记录详细统计信息。
Implementations§
Trait Implementations§
Source§impl HttpInterceptor for CommonInterceptor
impl HttpInterceptor for CommonInterceptor
Source§fn on_done(
&self,
stats: &HttpStats,
err: Option<&Error>,
) -> BoxFuture<'_, Result<(), Error>>
fn on_done( &self, stats: &HttpStats, err: Option<&Error>, ) -> BoxFuture<'_, Result<(), Error>>
请求完成后打印服务名、方法、路径、状态码、耗时等结构化日志。
Source§fn fail(&self, status: u16, data: &Bytes) -> BoxFuture<'_, Result<(), Error>>
fn fail(&self, status: u16, data: &Bytes) -> BoxFuture<'_, Result<(), Error>>
响应状态码 ≥400 时调用,可将错误信息转换为业务
Error。Source§fn request(
&self,
req: RequestBuilder,
) -> BoxFuture<'_, Result<RequestBuilder, Error>>
fn request( &self, req: RequestBuilder, ) -> BoxFuture<'_, Result<RequestBuilder, Error>>
发送前修改请求(如注入鉴权头、签名等)。
Auto Trait Implementations§
impl Freeze for CommonInterceptor
impl RefUnwindSafe for CommonInterceptor
impl Send for CommonInterceptor
impl Sync for CommonInterceptor
impl Unpin for CommonInterceptor
impl UnsafeUnpin for CommonInterceptor
impl UnwindSafe for CommonInterceptor
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