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: return 404 status code when route isn't found #380

Merged
merged 1 commit into from
Jan 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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