From 12796fecfe5e4c34ce1c75a8fa7e3ef87a2323fc Mon Sep 17 00:00:00 2001 From: Manuel Gugger Date: Wed, 8 Dec 2021 18:37:15 +0100 Subject: [PATCH] add admin scope --- src/actix-admin/mod.rs => database.db-wal | 0 src/actix_admin/mod.rs | 22 ++++++++++++++++++++++ src/main.rs | 2 ++ 3 files changed, 24 insertions(+) rename src/actix-admin/mod.rs => database.db-wal (100%) create mode 100644 src/actix_admin/mod.rs diff --git a/src/actix-admin/mod.rs b/database.db-wal similarity index 100% rename from src/actix-admin/mod.rs rename to database.db-wal diff --git a/src/actix_admin/mod.rs b/src/actix_admin/mod.rs new file mode 100644 index 0000000..c7fb4b6 --- /dev/null +++ b/src/actix_admin/mod.rs @@ -0,0 +1,22 @@ +use actix_web::{web, guard, HttpRequest, HttpResponse}; + +async fn index(data: web::Data) -> &'static str { + "Welcome!" +} + +async fn list(data: web::Data) -> &'static str { + "List!" +} + +fn entity_scope() -> actix_web::Scope { + let scope = web::scope("/entity") + .route("/list", web::get().to(list)); + scope +} + +pub fn admin_scope() -> actix_web::Scope { + let scope = web::scope("/admin") + .route("/", web::get().to(index)) + .service(entity_scope()); + scope +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index c684f63..eb80a38 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,6 +15,7 @@ use sea_orm::{{ DatabaseConnection, ConnectOptions }}; mod web_auth; mod entity; +mod actix_admin; #[derive(Debug, Clone)] pub struct AppState { @@ -96,6 +97,7 @@ async fn main() { App::new() .app_data(web::Data::new(app_state.clone())) .wrap(CookieSession::signed(&[0; 32]).secure(false)) + .service(actix_admin::admin_scope()) .route("/", web::get().to(index)) .route("/login", web::get().to(web_auth::login)) .route("/logout", web::get().to(web_auth::logout))