Replies: 1 comment
-
You have some options now, the docs mention two:
I think the second option here is what you're looking for? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Feature Request
Add a way to customize the error responses for
TypedHeader
.Motivation
Currently, failed
TypedHeader
extractors always return code 400 with a plain text message. This works alright for many cases, but it may be more applicable to return a different error code, a JSON response, or a full 400 error page.Proposal
My initial thought
TypedHeader<T>
generic over an error type that implementsFrom<TypedHeaderError>
andIntoResponse
, such as the below for the existing TypedHeaderRejection:The problem with this is that the current
TypedHeader<T>(pub T)
can't be made public over anything else without having a PhantomData field, which would break the API of function parameter destructuring likeTypedHeader(Authorization(bearer)): TypedHeader<Authorization<Bearer>>
.Alternatives
I don't know the best way to resolve the above issue outside of adding a new type. Const generics can be used without an extra PhantomData to customize only the error code:
But that doesn't allow for setting a custom output type in any way.
Beta Was this translation helpful? Give feedback.
All reactions