From da2d31a838f4d51a008d25995ad742b8e3dd7228 Mon Sep 17 00:00:00 2001 From: Jef Roosens Date: Fri, 26 Nov 2021 13:22:22 +0100 Subject: [PATCH] Made proxy not panic when not passing query --- src/proxy.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/proxy.rs b/src/proxy.rs index 53a7605..a9fcf3e 100644 --- a/src/proxy.rs +++ b/src/proxy.rs @@ -94,12 +94,18 @@ impl Handler for ProxyServer // We first extract all URL segments starting from the mountpoint let segments: PathBuf = req.segments(0..).unwrap(); + let query_part = if let Some(query) = req.uri().query() { + format!("?{}", query) + }else{ + String::from("") + }; + let url = format!( - "{}{}/{}?{}", + "{}{}/{}{}", self.root, self.prefix.to_str().unwrap(), segments.to_str().unwrap(), - req.uri().query().unwrap() + query_part ); // And finally, the data