Skip to content

Commit

Permalink
Return HTTP 404 rather than 405 (sigp#3836)
Browse files Browse the repository at this point in the history
Issue sigp#3112

Add `Filter::recover` to the GET chain to handle rejections specifically as 404 NOT FOUND

Making a request to `http://localhost:5052/not_real` now returns the following:

```
{
    "code": 404,
    "message": "NOT_FOUND",
    "stacktraces": []
}
```

Co-authored-by: Paul Hauner <paul@paulhauner.com>
  • Loading branch information
2 people authored and realbigsean committed Jan 25, 2023
1 parent 6511d28 commit bd7bd00
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions beacon_node/http_api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3491,7 +3491,8 @@ pub fn serve<T: BeaconChainTypes>(
.or(get_lighthouse_block_packing_efficiency.boxed())
.or(get_lighthouse_merge_readiness.boxed())
.or(get_lighthouse_blobs_sidecars.boxed())
.or(get_events.boxed()),
.or(get_events.boxed())
.recover(warp_utils::reject::handle_rejection),
)
.boxed()
.or(warp::post().and(
Expand All @@ -3516,7 +3517,8 @@ pub fn serve<T: BeaconChainTypes>(
.or(post_lighthouse_database_reconstruct.boxed())
.or(post_lighthouse_database_historical_blocks.boxed())
.or(post_lighthouse_block_rewards.boxed())
.or(post_lighthouse_ui_validator_metrics.boxed()),
.or(post_lighthouse_ui_validator_metrics.boxed())
.recover(warp_utils::reject::handle_rejection),
))
.recover(warp_utils::reject::handle_rejection)
.with(slog_logging(log.clone()))
Expand Down

0 comments on commit bd7bd00

Please sign in to comment.