pub struct ProblemJsonLayer;Expand description
Tower Layer that maps inner-service errors into Problem+JSON HTTP
responses.
Any Err propagated from the inner service is converted to an ApiError
via the Into<ApiError> bound and then serialized as
application/problem+json.
Successful responses are passed through unchanged.
§Example
use api_bones_tower::ProblemJsonLayer;
use tower::ServiceBuilder;
let _svc = ServiceBuilder::new()
.layer(ProblemJsonLayer::new())
.service(tower::service_fn(|_req: http::Request<()>| async {
Ok::<_, api_bones::ApiError>(http::Response::new(String::new()))
}));Implementations§
Trait Implementations§
Source§impl Clone for ProblemJsonLayer
impl Clone for ProblemJsonLayer
Source§fn clone(&self) -> ProblemJsonLayer
fn clone(&self) -> ProblemJsonLayer
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 ProblemJsonLayer
impl Debug for ProblemJsonLayer
Source§impl Default for ProblemJsonLayer
impl Default for ProblemJsonLayer
Source§fn default() -> ProblemJsonLayer
fn default() -> ProblemJsonLayer
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for ProblemJsonLayer
impl RefUnwindSafe for ProblemJsonLayer
impl Send for ProblemJsonLayer
impl Sync for ProblemJsonLayer
impl Unpin for ProblemJsonLayer
impl UnsafeUnpin for ProblemJsonLayer
impl UnwindSafe for ProblemJsonLayer
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