From 217c22c7541b9b1cc76d31adabbfc0803e0d0f22 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 15 Jul 2020 09:11:16 +0200 Subject: [PATCH] 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 --- src/server/h2service.rs | 2 +- src/server/rest.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/server/h2service.rs b/src/server/h2service.rs index 9689b282..453495d0 100644 --- a/src/server/h2service.rs +++ b/src/server/h2service.rs @@ -55,7 +55,7 @@ impl H2Service { 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) => { diff --git a/src/server/rest.rs b/src/server/rest.rs index 1e6c3d6c..d05e51ab 100644 --- a/src/server/rest.rs +++ b/src/server/rest.rs @@ -493,7 +493,7 @@ pub async fn handle_request(api: Arc, req: Request) -> Result, req: Request) -> Result { - 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, req: Request) -> Result