From 9d6eb613d489d755f0d3b5b18b4df6a363f68803 Mon Sep 17 00:00:00 2001 From: necrashter Date: Sat, 23 Apr 2022 15:43:13 +0300 Subject: Handle empty url_prefix --- src/routes.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/routes.rs b/src/routes.rs index 60e4ffa..9afe0ac 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -8,14 +8,20 @@ use warp::{Filter, filters::BoxedFilter, Rejection, Reply}; /// Every route combined for a single network pub fn network(db: Db) -> BoxedFilter<(impl Reply,)> { let url_prefix = db.config.url_prefix.clone(); - warp::path(url_prefix) - .and( - transaction_list(db.clone()) - .or(register_user(db.clone())) - .or(auth_transaction_propose(db.clone())) - .or(auth_block_propose(db.clone())) - .or(list_users(db.clone())) - .or(block_list(db)) + let root = if url_prefix.is_empty() { + // warp::path does not like empty url_prefix + // We need to handle this case separately + warp::any().boxed() + } else { + warp::path(url_prefix).boxed() + }; + root.and( + transaction_list(db.clone()) + .or(register_user(db.clone())) + .or(auth_transaction_propose(db.clone())) + .or(auth_block_propose(db.clone())) + .or(list_users(db.clone())) + .or(block_list(db)) ) .boxed() } -- cgit v1.2.3-70-g09d2