diff options
author | necrashter | 2022-04-23 15:43:13 +0300 |
---|---|---|
committer | Yigit Sever | 2022-04-23 18:10:12 +0300 |
commit | 9d6eb613d489d755f0d3b5b18b4df6a363f68803 (patch) | |
tree | 066b8c9863dfc7bce60649ebfe3e5ac835893f60 /src | |
parent | 85dc0418b8b3b7e6d10a4ae85878a921b67c9baf (diff) | |
download | gradecoin-9d6eb613d489d755f0d3b5b18b4df6a363f68803.tar.gz gradecoin-9d6eb613d489d755f0d3b5b18b4df6a363f68803.tar.bz2 gradecoin-9d6eb613d489d755f0d3b5b18b4df6a363f68803.zip |
Handle empty url_prefix
Diffstat (limited to 'src')
-rw-r--r-- | src/routes.rs | 22 |
1 files 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}; | |||
8 | /// Every route combined for a single network | 8 | /// Every route combined for a single network |
9 | pub fn network(db: Db) -> BoxedFilter<(impl Reply,)> { | 9 | pub fn network(db: Db) -> BoxedFilter<(impl Reply,)> { |
10 | let url_prefix = db.config.url_prefix.clone(); | 10 | let url_prefix = db.config.url_prefix.clone(); |
11 | warp::path(url_prefix) | 11 | let root = if url_prefix.is_empty() { |
12 | .and( | 12 | // warp::path does not like empty url_prefix |
13 | transaction_list(db.clone()) | 13 | // We need to handle this case separately |
14 | .or(register_user(db.clone())) | 14 | warp::any().boxed() |
15 | .or(auth_transaction_propose(db.clone())) | 15 | } else { |
16 | .or(auth_block_propose(db.clone())) | 16 | warp::path(url_prefix).boxed() |
17 | .or(list_users(db.clone())) | 17 | }; |
18 | .or(block_list(db)) | 18 | root.and( |
19 | transaction_list(db.clone()) | ||
20 | .or(register_user(db.clone())) | ||
21 | .or(auth_transaction_propose(db.clone())) | ||
22 | .or(auth_block_propose(db.clone())) | ||
23 | .or(list_users(db.clone())) | ||
24 | .or(block_list(db)) | ||
19 | ) | 25 | ) |
20 | .boxed() | 26 | .boxed() |
21 | } | 27 | } |