docs(examples): gateway: remove extra slash for uri (#2351)

The PathAndQuery already contains the leading slash, which erroneously
sets the proxied path to "//.." and not "/..".
This commit is contained in:
Jim Holmström
2020-12-03 22:36:32 +01:00
committed by GitHub
parent f8641733be
commit 3cb6b4e840

View File

@@ -26,9 +26,12 @@ async fn main() {
// returns a Response into a `Service`.
Ok::<_, Error>(service_fn(move |mut req| {
let uri_string = format!(
"http://{}/{}",
"http://{}{}",
out_addr_clone,
req.uri().path_and_query().map(|x| x.as_str()).unwrap_or("")
req.uri()
.path_and_query()
.map(|x| x.as_str())
.unwrap_or("/")
);
let uri = uri_string.parse().unwrap();
*req.uri_mut() = uri;