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

Nested routes are missing the allow header in 405 Method Not Allowed responses #1525

Closed
taylor1791 opened this issue Nov 12, 2022 · 4 comments

Comments

@taylor1791
Copy link
Contributor

Bug Report

Versions

axum v0.5.17
axum-core v0.2.9

Platform

Linux [hostname] 5.15.72 #1-NixOS SMP Wed Oct 5 08:39:44 UTC 2022 x86_64 GNU/Linux

Description

When the server replies with 405 from a nested route, it should include an allow header. As of axum 0.5.17, it does not.

Steps to reproduce:

Run this code:

use axum::{routing::get, Router};

#[tokio::main]
async fn main() {
    let router = Router::new().route("/hello", get(|| async { "Hello, World!" }));
    let app = Router::new().nest("/api", router);

    axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
        .serve(app.into_make_service())
        .await
        .unwrap();
}

Send a POST request to /api/hello.

$ curl -I -X POST http://localhost:3000/api/hello
HTTP/1.1 405 Method Not Allowed
content-length: 0
date: Sat, 12 Nov 2022 18:53:57 GMT

Observe that the response did not include an allow header.

The code in #731 still contains the reply header, indicating this is specific to .nest.

@taylor1791
Copy link
Contributor Author

I tried the same code on axum 0.6.0-rc.4 and the allow header is present.

@davidpdrsn
Copy link
Member

Good catch! I'm curious why that was but yeah if it's fixed in 0.6 then we are good.

@davidpdrsn
Copy link
Member

I think we should add a test for it though. Do you perhaps wanna make a PR?

@taylor1791
Copy link
Contributor Author

Yes! I would love to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants