[Rust Server] Preserve path provided in base path (#5555)

* Preserve path provided in base path
* Update samples
This commit is contained in:
Richard Whitehouse 2020-03-24 09:25:48 +00:00 committed by GitHub
parent 28ea718004
commit 05ace4f43f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 7 additions and 7 deletions

View File

@ -23,7 +23,7 @@ fn into_base_path(input: &str, correct_scheme: Option<&'static str>) -> Result<S
let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?; let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?;
let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default(); let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default();
Ok(format!("{}://{}{}", scheme, host, port)) Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/')))
} }
/// A client that implements the API by making HTTP calls out to a server. /// A client that implements the API by making HTTP calls out to a server.

View File

@ -62,7 +62,7 @@ fn into_base_path(input: &str, correct_scheme: Option<&'static str>) -> Result<S
let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?; let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?;
let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default(); let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default();
Ok(format!("{}://{}{}", scheme, host, port)) Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/')))
} }
/// A client that implements the API by making HTTP calls out to a server. /// A client that implements the API by making HTTP calls out to a server.

View File

@ -54,7 +54,7 @@ fn into_base_path(input: &str, correct_scheme: Option<&'static str>) -> Result<S
let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?; let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?;
let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default(); let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default();
Ok(format!("{}://{}{}", scheme, host, port)) Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/')))
} }
/// A client that implements the API by making HTTP calls out to a server. /// A client that implements the API by making HTTP calls out to a server.

View File

@ -76,7 +76,7 @@ fn into_base_path(input: &str, correct_scheme: Option<&'static str>) -> Result<S
let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?; let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?;
let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default(); let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default();
Ok(format!("{}://{}{}", scheme, host, port)) Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/')))
} }
/// A client that implements the API by making HTTP calls out to a server. /// A client that implements the API by making HTTP calls out to a server.

View File

@ -90,7 +90,7 @@ fn into_base_path(input: &str, correct_scheme: Option<&'static str>) -> Result<S
let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?; let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?;
let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default(); let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default();
Ok(format!("{}://{}{}", scheme, host, port)) Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/')))
} }
/// A client that implements the API by making HTTP calls out to a server. /// A client that implements the API by making HTTP calls out to a server.

View File

@ -93,7 +93,7 @@ fn into_base_path(input: &str, correct_scheme: Option<&'static str>) -> Result<S
let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?; let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?;
let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default(); let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default();
Ok(format!("{}://{}{}", scheme, host, port)) Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/')))
} }
/// A client that implements the API by making HTTP calls out to a server. /// A client that implements the API by making HTTP calls out to a server.

View File

@ -62,7 +62,7 @@ fn into_base_path(input: &str, correct_scheme: Option<&'static str>) -> Result<S
let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?; let host = uri.host().ok_or_else(|| ClientInitError::MissingHost)?;
let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default(); let port = uri.port_part().map(|x| format!(":{}", x)).unwrap_or_default();
Ok(format!("{}://{}{}", scheme, host, port)) Ok(format!("{}://{}{}{}", scheme, host, port, uri.path().trim_end_matches('/')))
} }
/// A client that implements the API by making HTTP calls out to a server. /// A client that implements the API by making HTTP calls out to a server.