Return HTTP 404 rather than 405 (#3836)

## Issue Addressed

Issue #3112

## Proposed Changes

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

## Additional Info

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>
This commit is contained in:
Santiago Medina 2023-01-16 03:42:09 +00:00
parent 4d9e137e6a
commit 912ea2a5ca

View File

@ -3383,7 +3383,8 @@ pub fn serve<T: BeaconChainTypes>(
.or(get_lighthouse_attestation_performance.boxed())
.or(get_lighthouse_block_packing_efficiency.boxed())
.or(get_lighthouse_merge_readiness.boxed())
.or(get_events.boxed()),
.or(get_events.boxed())
.recover(warp_utils::reject::handle_rejection),
)
.boxed()
.or(warp::post().and(
@ -3407,7 +3408,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()))