From 7d537214b7a337cc18440cc1827502219e988bee Mon Sep 17 00:00:00 2001 From: duguorong009 Date: Wed, 4 Oct 2023 00:43:29 +0000 Subject: [PATCH] fix(validator_client): return http 404 rather than 405 in http api (#4758) ## Issue Addressed - Close #4596 ## Proposed Changes - Add `Filter::recover` to handle rejections specifically as 404 NOT FOUND Please list or describe the changes introduced by this PR. ## Additional Info Similar to PR #3836 --- validator_client/src/http_api/mod.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/validator_client/src/http_api/mod.rs b/validator_client/src/http_api/mod.rs index f654833cb..669edc671 100644 --- a/validator_client/src/http_api/mod.rs +++ b/validator_client/src/http_api/mod.rs @@ -1176,7 +1176,8 @@ pub fn serve( .or(get_fee_recipient) .or(get_gas_limit) .or(get_std_keystores) - .or(get_std_remotekeys), + .or(get_std_remotekeys) + .recover(warp_utils::reject::handle_rejection), ) .or(warp::post().and( post_validators @@ -1187,15 +1188,18 @@ pub fn serve( .or(post_fee_recipient) .or(post_gas_limit) .or(post_std_keystores) - .or(post_std_remotekeys), + .or(post_std_remotekeys) + .recover(warp_utils::reject::handle_rejection), )) - .or(warp::patch().and(patch_validators)) + .or(warp::patch() + .and(patch_validators.recover(warp_utils::reject::handle_rejection))) .or(warp::delete().and( delete_lighthouse_keystores .or(delete_fee_recipient) .or(delete_gas_limit) .or(delete_std_keystores) - .or(delete_std_remotekeys), + .or(delete_std_remotekeys) + .recover(warp_utils::reject::handle_rejection), )), ) // The auth route and logs are the only routes that are allowed to be accessed without the API token.