From 8213d5715e52b3bff38f8ccfb5e0717a2becb075 Mon Sep 17 00:00:00 2001 From: Yigit Sever Date: Tue, 13 Apr 2021 15:36:57 +0300 Subject: Refactor authorized propose functions They were getting spaghetti so; new function: handlers::authorize_proposer(), handles the jwt stuff, NOT async and _may_ cause trouble down the road but then again the stuff it does used to be (repeated) in the functions so how bad can it be If else chains were getting unwieldy; https://refactoring.com/catalog/replaceNestedConditionalWithGuardClauses.html so now everything is returning early, might make verbose error handling easier --- src/routes.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/routes.rs') diff --git a/src/routes.rs b/src/routes.rs index 0fb61c4..280de35 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -48,7 +48,7 @@ pub fn auth_transaction_propose( .and(custom_filters::transaction_json_body()) .and(custom_filters::auth_header()) .and(custom_filters::with_db(db)) - .and_then(handlers::auth_propose_transaction) + .and_then(handlers::authorized_propose_transaction) } /// POST /block warp route @@ -58,6 +58,6 @@ pub fn auth_block_propose(db: Db) -> impl Filter