add admin scope
This commit is contained in:
parent
bb545ab742
commit
12796fecfe
22
src/actix_admin/mod.rs
Normal file
22
src/actix_admin/mod.rs
Normal file
@ -0,0 +1,22 @@
|
||||
use actix_web::{web, guard, HttpRequest, HttpResponse};
|
||||
|
||||
async fn index(data: web::Data<super::AppState>) -> &'static str {
|
||||
"Welcome!"
|
||||
}
|
||||
|
||||
async fn list(data: web::Data<super::AppState>) -> &'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
|
||||
}
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user