-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update route implementation (#16)
* chore: enable the support modified * feat: set routes per feature * fix: remove ; * chore: change ip database to localhost
- Loading branch information
Showing
8 changed files
with
69 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,17 @@ | ||
use actix_web::web; | ||
|
||
use crate::{ | ||
features::{auth::auth_controller, general::general_controller, user::user_controller}, | ||
features::{auth::routes::auth_scope, general::routes::general_scope, user::routes::user_scope}, | ||
utils::handler::route_not_found, | ||
}; | ||
|
||
pub fn config_services(cfg: &mut web::ServiceConfig) { | ||
// Configuring routes | ||
cfg.service( | ||
web::scope("/api") | ||
.service( | ||
web::scope("/general") | ||
.service( | ||
web::resource("/send_email") | ||
.route(web::post().to(general_controller::mail_sender_controller)), | ||
) | ||
.service( | ||
web::resource("/health_checker") | ||
.route(web::get().to(general_controller::health_checker_controller)), | ||
), | ||
) | ||
.service( | ||
web::scope("/auth") | ||
.service( | ||
web::resource("/general") | ||
.route(web::post().to(auth_controller::general_token_controller)), | ||
) | ||
.service( | ||
web::resource("/login") | ||
.route(web::post().to(auth_controller::login_contoller)), | ||
) | ||
.service( | ||
web::resource("/logout") | ||
.route(web::post().to(auth_controller::logout_controller)), | ||
) | ||
.service( | ||
web::resource("/session") | ||
.route(web::get().to(auth_controller::login_session_controller)), | ||
) | ||
.service( | ||
web::resource("/password") | ||
.route(web::put().to(auth_controller::update_password_controller)), | ||
), | ||
) | ||
.service( | ||
web::scope("/user") | ||
.service( | ||
web::resource("") | ||
.route(web::post().to(user_controller::register_controller)) | ||
.route(web::get().to(user_controller::get_user)) | ||
.route(web::put().to(user_controller::update_user_controller)) | ||
.route(web::delete().to(user_controller::delete_user_controller)), | ||
) | ||
.service( | ||
web::resource("/all") | ||
.route(web::get().to(user_controller::users_controller)), | ||
), | ||
), | ||
.service(general_scope()) | ||
.service(auth_scope()) | ||
.service(user_scope()), | ||
) | ||
.default_service(web::route().to(route_not_found)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod auth_controller; | ||
pub mod data; | ||
pub mod domain; | ||
pub mod routes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use actix_web::web; | ||
|
||
use super::auth_controller; | ||
|
||
pub fn auth_scope() -> actix_web::Scope { | ||
web::scope("/auth") | ||
.service( | ||
web::resource("/general") | ||
.route(web::post().to(auth_controller::general_token_controller)), | ||
) | ||
.service( | ||
web::resource("/login") | ||
.route(web::post().to(auth_controller::login_contoller)), // Fixed typo: login_contoller -> login_controller | ||
) | ||
.service( | ||
web::resource("/logout") | ||
.route(web::post().to(auth_controller::logout_controller)), | ||
) | ||
.service( | ||
web::resource("/session") | ||
.route(web::get().to(auth_controller::login_session_controller)), | ||
) | ||
.service( | ||
web::resource("/password") | ||
.route(web::put().to(auth_controller::update_password_controller)), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod domain; | ||
pub mod general_controller; | ||
pub mod routes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
use actix_web::web; | ||
|
||
use super::general_controller; | ||
|
||
pub fn general_scope() -> actix_web::Scope { | ||
web::scope("/general") | ||
.service( | ||
web::resource("/send_email") | ||
.route(web::post().to(general_controller::mail_sender_controller)), | ||
) | ||
.service( | ||
web::resource("/health_checker") | ||
.route(web::get().to(general_controller::health_checker_controller)), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod data; | ||
pub mod domain; | ||
pub mod user_controller; | ||
pub mod routes; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use actix_web::web; | ||
|
||
use super::user_controller; | ||
|
||
pub fn user_scope() -> actix_web::Scope { | ||
web::scope("/user") | ||
.service( | ||
web::resource("") | ||
.route(web::post().to(user_controller::register_controller)) | ||
.route(web::get().to(user_controller::get_user)) | ||
.route(web::put().to(user_controller::update_user_controller)) | ||
.route(web::delete().to(user_controller::delete_user_controller)), | ||
) | ||
.service( | ||
web::resource("/all") | ||
.route(web::get().to(user_controller::users_controller)), | ||
) | ||
} |