From a2d54ad8a3d835f4e2eada8b7ab80bbce2f8d20c Mon Sep 17 00:00:00 2001 From: Sergey Date: Thu, 31 Oct 2024 12:12:34 +0300 Subject: [PATCH] Add custom 404 for REST --- rest/src/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/rest/src/main.rs b/rest/src/main.rs index 23b9b78d..664c4c67 100644 --- a/rest/src/main.rs +++ b/rest/src/main.rs @@ -1454,9 +1454,19 @@ impl Fairing for CORS { } } + +#[catch(404)] +fn not_found(req: &Request) -> Value { + json!({ + "code": 12, + "message": "Not Implemented", + "details": [] + }) +} + #[launch] fn rocket() -> _ { - rocket::build().attach(CORS).mount( + rocket::build().attach(CORS).register("/", catchers![not_found]).mount( "/", routes![ bank_balances,