diff --git a/examples/404.rs b/examples/404.rs index 76c9ce6d..f837caa1 100644 --- a/examples/404.rs +++ b/examples/404.rs @@ -39,12 +39,14 @@ async fn handler() -> response::Html<&'static str> { } fn map_404(response: Response) -> Response { - if response.status() != StatusCode::NOT_FOUND { - return response; + if response.status() == StatusCode::NOT_FOUND + || response.status() == StatusCode::METHOD_NOT_ALLOWED + { + return Response::builder() + .status(StatusCode::NOT_FOUND) + .body(box_body(Body::from("nothing to see here"))) + .unwrap(); } - Response::builder() - .status(StatusCode::NOT_FOUND) - .body(box_body(Body::from("nothing to see here"))) - .unwrap() + response }