Provide access to rejection body strings as used in impl IntoResponse
#1611
Labels
A-axum
C-feature-request
Category: A feature request, i.e: not implemented / a PR.
E-easy
Call for participation: Experience needed to fix: Easy / not much
Feature Request
Motivation
There is currently no way to access the body string used by rejections in their
IntoResponse
impl. That makes customizing rejections a little cumbersome if you just wanna wrap the default text in JSON. See #1610 for context.We do implement
Display
but that doesn't include the source error (as it shouldn't). We only do that in theIntoResponse
impl.Proposal
Add an
fn body_text(&self) -> String
method that returns theIntoResponse
body.impl IntoResponse for $rejection
can then call that method.Alternatives
Require users to downcast errors or otherwise handle this themselves.
The text was updated successfully, but these errors were encountered: