refactor routing

This commit is contained in:
Rohan Sircar 2021-05-06 12:52:14 +05:30
parent 4d1118eb36
commit aa6b788669
2 changed files with 13 additions and 6 deletions

View File

@ -54,12 +54,21 @@ pub fn configure_app(app_data: AppData) -> Box<dyn Fn(&mut ServiceConfig)> {
cfg.data(app_data.clone()) cfg.data(app_data.clone())
.service( .service(
web::scope("/api") web::scope("/api")
.service(routes::users::get_user) .service(
.service(routes::users::get_all_users) web::scope("/users")
.service(web::scope("/get").route( .route(
"",
web::get().to(routes::users::get_all_users),
)
.route(
"/{user_id}",
web::get().to(routes::users::get_user),
),
)
.route(
"/build-info", "/build-info",
web::get().to(routes::misc::build_info_req), web::get().to(routes::misc::build_info_req),
)), ),
) )
// .route("/api/users/get", web::get().to(user_controller.get_user.into())) // .route("/api/users/get", web::get().to(user_controller.get_user.into()))
.service(web::scope("/api/public")) // public endpoint - not implemented yet .service(web::scope("/api/public")) // public endpoint - not implemented yet

View File

@ -7,7 +7,6 @@ use actix_web::error::ResponseError;
use validator::Validate; use validator::Validate;
/// Finds user by UID. /// Finds user by UID.
#[get("/get/users/{user_id}")]
pub async fn get_user( pub async fn get_user(
app_data: web::Data<AppData>, app_data: web::Data<AppData>,
user_id: web::Path<i32>, user_id: web::Path<i32>,
@ -50,7 +49,6 @@ pub async fn get_user2(
} }
} }
#[get("/get/users")]
pub async fn get_all_users( pub async fn get_all_users(
app_data: web::Data<AppData>, app_data: web::Data<AppData>,
) -> Result<HttpResponse, DomainError> { ) -> Result<HttpResponse, DomainError> {