summaryrefslogtreecommitdiffstats
path: root/src/routes.rs
diff options
context:
space:
mode:
authorYigit Sever2021-04-13 15:36:57 +0300
committerYigit Sever2021-04-13 15:40:03 +0300
commitc0b2e354621ef1a66eaa7f12c119b825ab1ad522 (patch)
tree697429c5374bb1c6a4935768b201c67a08031372 /src/routes.rs
parent909f5317117594e4bc956d558a22698d59fd8129 (diff)
downloadgradecoin-c0b2e354621ef1a66eaa7f12c119b825ab1ad522.tar.gz
gradecoin-c0b2e354621ef1a66eaa7f12c119b825ab1ad522.tar.bz2
gradecoin-c0b2e354621ef1a66eaa7f12c119b825ab1ad522.zip
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
Diffstat (limited to 'src/routes.rs')
-rw-r--r--src/routes.rs4
1 files changed, 2 insertions, 2 deletions
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(
48 .and(custom_filters::transaction_json_body()) 48 .and(custom_filters::transaction_json_body())
49 .and(custom_filters::auth_header()) 49 .and(custom_filters::auth_header())
50 .and(custom_filters::with_db(db)) 50 .and(custom_filters::with_db(db))
51 .and_then(handlers::auth_propose_transaction) 51 .and_then(handlers::authorized_propose_transaction)
52} 52}
53 53
54/// POST /block warp route 54/// POST /block warp route
@@ -58,6 +58,6 @@ pub fn auth_block_propose(db: Db) -> impl Filter<Extract = impl Reply, Error = R
58 .and(custom_filters::block_json_body()) 58 .and(custom_filters::block_json_body())
59 .and(custom_filters::auth_header()) 59 .and(custom_filters::auth_header())
60 .and(custom_filters::with_db(db)) 60 .and(custom_filters::with_db(db))
61 .and_then(handlers::auth_propose_block) 61 .and_then(handlers::authorized_propose_block)
62} 62}
63 63