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:
parent
ba5b8a3e76
commit
217c22c754
@ -55,7 +55,7 @@ impl <E: RpcEnvironment + Clone> H2Service<E> {
|
|||||||
|
|
||||||
match self.router.find_method(&components, method, &mut uri_param) {
|
match self.router.find_method(&components, method, &mut uri_param) {
|
||||||
None => {
|
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()
|
future::ok((formatter.format_error)(err)).boxed()
|
||||||
}
|
}
|
||||||
Some(api_method) => {
|
Some(api_method) => {
|
||||||
|
@ -493,7 +493,7 @@ pub async fn handle_request(api: Arc<ApiConfig>, req: Request<Body>) -> Result<R
|
|||||||
let (parts, body) = req.into_parts();
|
let (parts, body) = req.into_parts();
|
||||||
|
|
||||||
let method = parts.method.clone();
|
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();
|
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) {
|
match api.find_method(&components[2..], method, &mut uri_param) {
|
||||||
None => {
|
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));
|
return Ok((formatter.format_error)(err));
|
||||||
}
|
}
|
||||||
Some(api_method) => {
|
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()))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user