Initial commit.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
extern crate core;
|
||||
|
||||
use crate::user::handler::{create_new_user, delete_by_id, get_all_users, initialise, login, update_user, update_user_password};
|
||||
use crate::user::validator::validator;
|
||||
use actix_web::web::ServiceConfig;
|
||||
use actix_web::{get, web, HttpResponse, Responder};
|
||||
use actix_web_httpauth::middleware::HttpAuthentication;
|
||||
|
||||
pub mod user;
|
||||
|
||||
#[get("/health")]
|
||||
async fn health() -> impl Responder {
|
||||
"Ok!"
|
||||
}
|
||||
|
||||
pub fn init(cfg: &mut ServiceConfig) {
|
||||
cfg.service(health)
|
||||
.service(health)
|
||||
.service(initialise)
|
||||
.service(login)
|
||||
.service(
|
||||
web::scope("")
|
||||
.wrap(HttpAuthentication::bearer(validator))
|
||||
.service(create_new_user)
|
||||
.service(update_user)
|
||||
.service(update_user_password)
|
||||
.service(get_all_users)
|
||||
.service(delete_by_id)
|
||||
);
|
||||
|
||||
cfg.default_service(web::to(not_found));
|
||||
}
|
||||
|
||||
async fn not_found() -> impl Responder {
|
||||
HttpResponse::NotFound().finish()
|
||||
}
|
||||
Reference in New Issue
Block a user