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))