server: add path value to NOT_FOUND http error

Especially helpful for requests not coming from browsers (where the
URL is normally easy to find out).

Makes it easier to detect if one triggered a request with an old
client, or so..

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2020-07-15 09:11:16 +02:00
parent ba5b8a3e76
commit 217c22c754
2 changed files with 4 additions and 4 deletions

View File

@ -55,7 +55,7 @@ impl <E: RpcEnvironment + Clone> H2Service<E> {
match self.router.find_method(&components, method, &mut uri_param) {
None => {
let err = http_err!(NOT_FOUND, "Path not found.".to_string());
let err = http_err!(NOT_FOUND, format!("Path '{}' not found.", path).to_string());
future::ok((formatter.format_error)(err)).boxed()
}
Some(api_method) => {

View File

@ -493,7 +493,7 @@ pub async fn handle_request(api: Arc<ApiConfig>, req: Request<Body>) -> Result<R
let (parts, body) = req.into_parts();
let method = parts.method.clone();
let (_path, components) = tools::normalize_uri_path(parts.uri.path())?;
let (path, components) = tools::normalize_uri_path(parts.uri.path())?;
let comp_len = components.len();
@ -542,7 +542,7 @@ pub async fn handle_request(api: Arc<ApiConfig>, req: Request<Body>) -> Result<R
match api.find_method(&components[2..], method, &mut uri_param) {
None => {
let err = http_err!(NOT_FOUND, "Path not found.".to_string());
let err = http_err!(NOT_FOUND, format!("Path '{}' not found.", path).to_string());
return Ok((formatter.format_error)(err));
}
Some(api_method) => {
@ -596,5 +596,5 @@ pub async fn handle_request(api: Arc<ApiConfig>, req: Request<Body>) -> Result<R
}
}
Err(http_err!(NOT_FOUND, "Path not found.".to_string()))
Err(http_err!(NOT_FOUND, format!("Path '{}' not found.", path).to_string()))
}