]> git.proxmox.com Git - proxmox-backup.git/commitdiff
server: add path value to NOT_FOUND http error
authorThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 15 Jul 2020 07:11:16 +0000 (09:11 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 16 Jul 2020 10:46:51 +0000 (12:46 +0200)
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>
src/server/h2service.rs
src/server/rest.rs

index 9689b282cfadaca8032b5c0a067ffdd8d6ad832f..453495d06de1350fe902dbec7bf7afd8d3ac6073 100644 (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) => {
index 1e6c3d6c1e4eed9748d4da78116907a447c9c48d..d05e51ab233ce4f823defddc6bed854479237d65 100644 (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()))
 }