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

Fix missing Allow when middleware are applied to MethodRouter #1773

Merged
merged 2 commits into from Feb 20, 2023

Conversation

davidpdrsn
Copy link
Member

Fixes #1770

To be totally honest I don't understand why this fixes the issue. I also noticed some weirdness in this piece of the code in https://github.com/tokio-rs/axum/pull/1711/files#r1082406463. Removing it doesn't seem to break anything else, and the bug it was originally added to fix doesn't occur anymore.

The reason its pretty hard to follow I think is that we wrap things in Route quite a bit, which also wraps the response future in RouteFuture. So there are several layers of RouteFuture being called and previously mutating the response.

Fixes #1770

To be totally honest I don't understand why this fixes the issue.
@@ -155,9 +155,6 @@ where

#[inline]
fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
#[derive(Clone, Copy)]
struct AlreadyPassedThroughRouteFuture;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe dig up the PR that introduced this via git blame?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did that here

tbh I'm not totally sure why everything still worked after removing this. Doesn't seem related to this change because it also works on main if you remove this. So must be something else that changed 🤷

#755 did add a regression test and I also tried the repro from #747. Both worked correctly.

and tested specifically the repro from the issue and everything worked fine. So something else must have changed that made AlreadyPassedThroughRouteFuture unnecessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, great 🙂

@davidpdrsn
Copy link
Member Author

Oh yeah theres a failing tests. That interesting 😅

@davidpdrsn davidpdrsn merged commit 1e2567c into main Feb 20, 2023
@davidpdrsn davidpdrsn deleted the fix-missing-allow-header branch February 20, 2023 21:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow Header from 405 response is lost through service layers unless the route is .nested
2 participants