Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide access to rejection body strings as used in impl IntoResponse #1611

Closed
davidpdrsn opened this issue Dec 2, 2022 · 0 comments · Fixed by #1612
Closed

Provide access to rejection body strings as used in impl IntoResponse #1611

davidpdrsn opened this issue Dec 2, 2022 · 0 comments · Fixed by #1612
Assignees
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

Comments

@davidpdrsn
Copy link
Member

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 the IntoResponse impl.

Proposal

Add an fn body_text(&self) -> String method that returns the IntoResponse body. impl IntoResponse for $rejection can then call that method.

Alternatives

Require users to downcast errors or otherwise handle this themselves.

@davidpdrsn davidpdrsn added 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 A-axum labels Dec 2, 2022
@davidpdrsn davidpdrsn self-assigned this Dec 2, 2022
davidpdrsn added a commit that referenced this issue Dec 2, 2022
This should make it easier to customize a built-in rejection while
preserving either the status or body.

Fixes #1611
davidpdrsn added a commit that referenced this issue Dec 2, 2022
* Add `status` and `body_text` methods to built-in rejections

This should make it easier to customize a built-in rejection while
preserving either the status or body.

Fixes #1611

* changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant