pub struct ErrorResponseTransformer { /* private fields */ }Expand description
Interceptor that transforms error responses.
Useful for:
- Hiding internal error details in production
- Adding consistent error formatting
- Logging error responses
§Example
ⓘ
let interceptor = ErrorResponseTransformer::new()
.hide_details_for_status(StatusCode::INTERNAL_SERVER_ERROR)
.with_replacement_body(b"An internal error occurred".to_vec());Implementations§
Source§impl ErrorResponseTransformer
impl ErrorResponseTransformer
Sourcepub fn hide_details_for_status(self, status: StatusCode) -> Self
pub fn hide_details_for_status(self, status: StatusCode) -> Self
Hide details for the given status code.
Sourcepub fn with_replacement_body(self, body: impl Into<Vec<u8>>) -> Self
pub fn with_replacement_body(self, body: impl Into<Vec<u8>>) -> Self
Set the replacement body for error responses.
Sourcepub fn add_error_id(self, enable: bool) -> Self
pub fn add_error_id(self, enable: bool) -> Self
Enable adding an error ID header for tracking.
Trait Implementations§
Source§impl Clone for ErrorResponseTransformer
impl Clone for ErrorResponseTransformer
Source§fn clone(&self) -> ErrorResponseTransformer
fn clone(&self) -> ErrorResponseTransformer
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 Debug for ErrorResponseTransformer
impl Debug for ErrorResponseTransformer
Source§impl Default for ErrorResponseTransformer
impl Default for ErrorResponseTransformer
Auto Trait Implementations§
impl Freeze for ErrorResponseTransformer
impl RefUnwindSafe for ErrorResponseTransformer
impl Send for ErrorResponseTransformer
impl Sync for ErrorResponseTransformer
impl Unpin for ErrorResponseTransformer
impl UnwindSafe for ErrorResponseTransformer
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).