From 48004dfffe4c7a57aa8773c09a562f9ea5e1e9ca Mon Sep 17 00:00:00 2001 From: Fuwn Date: Mon, 25 Apr 2022 01:13:51 -0700 Subject: refactor(router): move error handler to constant --- src/main.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index b3820d5..a1beda9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -46,6 +46,10 @@ use windmark::{Response, Router}; use yarte::Template; const SEARCH_SIZE: usize = 10; +const ERROR_HANDLER_RESPONSE: &str = + "The requested resource could not be found at this time. You can try \ + refreshing the page, if that doesn't change anything; contact Fuwn! \ + (contact@fuwn.me)"; static DATABASE: SyncLazy> = SyncLazy::new(|| { Mutex::new({ @@ -130,12 +134,7 @@ async fn main() -> Result<(), Box> { .unwrap(); })); router.set_error_handler(Box::new(|_| { - Response::NotFound( - "The requested resource could not be found at this time. You can try \ - refreshing the page, if that doesn't change anything; contact Fuwn! \ - (contact@fuwn.me)" - .into(), - ) + Response::NotFound(ERROR_HANDLER_RESPONSE.into()) })); router.set_fix_path(true); -- cgit v1.2.3