diff --git a/src/controllers/account_controller.rs b/src/controllers/account_controller.rs new file mode 100644 index 0000000..b8e4f20 --- /dev/null +++ b/src/controllers/account_controller.rs @@ -0,0 +1,11 @@ +use crate::data::http_request_handler::HttpRequestHandler; +use crate::controllers::routes::RequestResult; + +/// Account controller +/// +/// @author Pierre Hubert + +/// Sign in user +pub fn login_user(request: &mut HttpRequestHandler) -> RequestResult { + request.success("Login user") +} \ No newline at end of file diff --git a/src/controllers/mod.rs b/src/controllers/mod.rs index f39aab8..d3d326b 100644 --- a/src/controllers/mod.rs +++ b/src/controllers/mod.rs @@ -1,4 +1,5 @@ pub mod routes; pub mod server; -pub mod server_controller; \ No newline at end of file +pub mod server_controller; +pub mod account_controller; \ No newline at end of file diff --git a/src/controllers/routes.rs b/src/controllers/routes.rs index b7a1447..f89232f 100644 --- a/src/controllers/routes.rs +++ b/src/controllers/routes.rs @@ -1,7 +1,7 @@ use std::error::Error; -use crate::controllers::routes::Method::GET; -use crate::controllers::server_controller; +use crate::controllers::routes::Method::{GET, POST}; +use crate::controllers::{server_controller, account_controller}; use crate::data::http_request_handler::HttpRequestHandler; /// Project routes @@ -42,12 +42,25 @@ impl Route { func } } + + pub fn post_without_login(uri: &'static str, func: RequestProcess) -> Route { + Route { + method: POST, + need_login: false, + uri, + func + } + } } /// Get the list of routes available pub fn get_routes() -> Vec { vec![ // Server meta routes - Route::get_without_login("/", Box::new(server_controller::main_index)) + Route::get_without_login("/", Box::new(server_controller::main_index)), + + // Account controller + Route::post_without_login("/account/login", Box::new(account_controller::login_user)), + Route::post_without_login("/account/connectUSER", Box::new(account_controller::login_user)), ] } \ No newline at end of file