Skip to content

Commit

Permalink
fix: return 404 status code when route isn't found (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoineRR authored Jan 30, 2023
1 parent 3aed256 commit 940ee51
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 6 additions & 0 deletions integration_tests/test_status_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ def test_404_post_request_status_code(session):
assert r.status_code == 404


def test_404_not_found(session):
r = requests.get(f"{BASE_URL}/actually_not_found_route")
assert r.status_code == 404
assert r.text == "Not found"


def test_307_get_request(session):
r = requests.get(f"{BASE_URL}/redirect")
assert r.text == "This is the redirected route"
Expand Down
3 changes: 2 additions & 1 deletion src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,8 @@ async fn index(
}
}
} else {
response_builder.finish()
response_builder.status(StatusCode::NOT_FOUND);
response_builder.body("Not found")
};

apply_middleware(
Expand Down

0 comments on commit 940ee51

Please sign in to comment.