From 9b7bf77a0ac4a32132908859e50373be8d8a0375 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Thu, 21 May 2020 15:39:20 +0200 Subject: [PATCH] Simplify routes definition --- src/controllers/routes.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/controllers/routes.rs b/src/controllers/routes.rs index 396d466..b7a1447 100644 --- a/src/controllers/routes.rs +++ b/src/controllers/routes.rs @@ -32,10 +32,22 @@ pub struct Route { pub func: RequestProcess, } +impl Route { + + pub fn get_without_login(uri: &'static str, func: RequestProcess) -> Route { + Route { + method: GET, + need_login: false, + uri, + func + } + } +} + /// Get the list of routes available pub fn get_routes() -> Vec { vec![ // Server meta routes - Route { method: GET, uri: "/", need_login: false, func: Box::new(server_controller::main_index) } + Route::get_without_login("/", Box::new(server_controller::main_index)) ] } \ No newline at end of file