Skip to content

Rocket should show 405 instead of 404 for method not allowed #1224

@silvioprog

Description

@silvioprog

Hi.

Consider the following route:

#[post("/hello")]
pub fn hello() -> &'static str {
    "Hello"
}

now, if you call it with:

curl http://localhost:8000/hello

it returns:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <title>404 Not Found</title>
  </head>
  <body align="center">
    <div align="center">
      <h1>404: Not Found</h1>
      <p>The requested resource could not be found.</p>
      <hr />
      <small>Rocket</small>
    </div>
  </body>
</html>

however, since the passed URL is correct and only the method (verb) is wrong, according to rfc7231#section-6.5.5, it should return 405: Method Not Allowed with an Allow header field in a 405 response containing a list of the target resource's currently supported methods.

So, if you don't agree with that, could you provide a global option to send 405 instead of 404 for handling method not allowed errors?

TIA

Metadata

Metadata

Assignees

No one assigned

    Labels

    requestRequest for new functionality

    Type

    No type

    Projects

    Status

    Backlog

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions