Move admin module into app module
This commit is contained in:
parent
1fab78ff96
commit
841b16986b
|
|
@ -22,7 +22,7 @@ use {
|
||||||
serde::Deserialize,
|
serde::Deserialize,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::app::AppState;
|
use super::AppState;
|
||||||
|
|
||||||
pub fn routes<D: Database>() -> Router<AppState<D>> {
|
pub fn routes<D: Database>() -> Router<AppState<D>> {
|
||||||
Router::new()
|
Router::new()
|
||||||
|
|
@ -4,13 +4,17 @@ use {
|
||||||
axum::{routing::get, Router},
|
axum::{routing::get, Router},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub mod admin;
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
pub struct AppState<D: Database> {
|
pub struct AppState<D: Database> {
|
||||||
pub db: D,
|
pub db: D,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn routes<D:Database>() -> Router<AppState<D>> {
|
pub fn routes<D: Database>() -> Router<AppState<D>> {
|
||||||
Router::new().route("/", get(root))
|
Router::new()
|
||||||
|
.route("/", get(root))
|
||||||
|
.nest("/admin", admin::routes())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Template)]
|
#[derive(Template)]
|
||||||
|
|
@ -4,7 +4,6 @@ use {
|
||||||
tracing::Level,
|
tracing::Level,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod admin;
|
|
||||||
mod app;
|
mod app;
|
||||||
mod authentication;
|
mod authentication;
|
||||||
mod config;
|
mod config;
|
||||||
|
|
@ -54,7 +53,6 @@ async fn locality_main() -> Result<(), Error> {
|
||||||
db_pool.migrate_to_current_version().await.unwrap();
|
db_pool.migrate_to_current_version().await.unwrap();
|
||||||
|
|
||||||
let app = app::routes()
|
let app = app::routes()
|
||||||
.nest("/admin", admin::routes())
|
|
||||||
.with_state(app::AppState { db: db_pool })
|
.with_state(app::AppState { db: db_pool })
|
||||||
.nest_service("/static", ServeDir::new(&config.static_file_path))
|
.nest_service("/static", ServeDir::new(&config.static_file_path))
|
||||||
.layer(TraceLayer::new_for_http());
|
.layer(TraceLayer::new_for_http());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue