-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add map_request
and friends
#1408
Conversation
/// async fn auth<B>(request: Request<B>) -> Result<Request<B>, StatusCode> { | ||
/// let auth_header = request.headers() | ||
/// .get(http::header::AUTHORIZATION) | ||
/// .and_then(|header| header.to_str().ok()); | ||
/// | ||
/// match auth_header { | ||
/// Some(auth_header) if token_is_valid(auth_header) => Ok(request), | ||
/// _ => Err(StatusCode::UNAUTHORIZED), | ||
/// } | ||
/// } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a new "simplest way to write an auth middleware", which feels like one of our most frequently asked questions 🥳
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda wanna nuke tower-http's auth middleware. They're so much more complicated than just doing this.
}; | ||
} | ||
|
||
impl_service!([], T1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At this point, should all_the_tuples!
just be updated to this pattern instead of the array-free one? Idk whether I've said this elsewhere but my idea to get rid of the array syntax in these macros turned out to not really work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I think it should. Its only HandleError
that uses the old version https://github.com/tokio-rs/axum/blob/main/axum/src/error_handling/mod.rs#L207. I'll do that separately.
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Co-authored-by: Jonas Platte <jplatte+git@posteo.de>
Fixes #1394 (comment)
I'll do
map_response
in a separate PR.