97 lines
3.9 KiB
Rust
97 lines
3.9 KiB
Rust
|
|
pub mod auth;
|
||
|
|
pub mod backlog_ncl;
|
||
|
|
pub mod drift_watcher;
|
||
|
|
pub mod handlers;
|
||
|
|
pub mod login;
|
||
|
|
pub mod qa_ncl;
|
||
|
|
pub mod watcher;
|
||
|
|
|
||
|
|
pub use drift_watcher::DriftWatcher;
|
||
|
|
pub use watcher::TemplateWatcher;
|
||
|
|
|
||
|
|
use crate::api::AppState;
|
||
|
|
|
||
|
|
pub fn router(state: AppState) -> axum::Router {
|
||
|
|
if state.registry.is_some() {
|
||
|
|
multi_router(state)
|
||
|
|
} else {
|
||
|
|
single_router(state)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
fn single_router(state: AppState) -> axum::Router {
|
||
|
|
use axum::routing::{get, post};
|
||
|
|
axum::Router::new()
|
||
|
|
.route("/", get(handlers::dashboard))
|
||
|
|
.route("/graph", get(handlers::graph))
|
||
|
|
.route("/sessions", get(handlers::sessions))
|
||
|
|
.route("/notifications", get(handlers::notifications_page))
|
||
|
|
.route("/modes", get(handlers::modes))
|
||
|
|
.route("/search", get(handlers::search_page))
|
||
|
|
.route("/assets/{*path}", get(handlers::serve_asset_single))
|
||
|
|
.route("/public/{*path}", get(handlers::serve_public_single))
|
||
|
|
.route("/backlog", get(handlers::backlog_page))
|
||
|
|
.route("/backlog/status", post(handlers::backlog_update_status))
|
||
|
|
.route("/backlog/add", post(handlers::backlog_add))
|
||
|
|
.route("/manage", get(handlers::manage_page))
|
||
|
|
.route("/manage/add", post(handlers::manage_add))
|
||
|
|
.route("/manage/remove", post(handlers::manage_remove))
|
||
|
|
.route("/actions", get(handlers::actions_page))
|
||
|
|
.route("/actions/run", post(handlers::actions_run))
|
||
|
|
.route("/qa", get(handlers::qa_page))
|
||
|
|
.route("/qa/delete", post(handlers::qa_delete))
|
||
|
|
.route("/qa/update", post(handlers::qa_update))
|
||
|
|
.with_state(state)
|
||
|
|
}
|
||
|
|
|
||
|
|
fn multi_router(state: AppState) -> axum::Router {
|
||
|
|
use axum::routing::{get, post};
|
||
|
|
axum::Router::new()
|
||
|
|
// Project picker and management at root
|
||
|
|
.route("/", get(handlers::project_picker))
|
||
|
|
.route("/manage", get(handlers::manage_page_guarded))
|
||
|
|
.route("/manage/add", post(handlers::manage_add_guarded))
|
||
|
|
.route("/manage/remove", post(handlers::manage_remove_guarded))
|
||
|
|
// Per-project routes — AuthUser extractor enforces auth per project
|
||
|
|
.route("/{slug}/", get(handlers::dashboard_mp))
|
||
|
|
.route("/{slug}/graph", get(handlers::graph_mp))
|
||
|
|
.route("/{slug}/sessions", get(handlers::sessions_mp))
|
||
|
|
.route("/{slug}/notifications", get(handlers::notifications_mp))
|
||
|
|
.route("/{slug}/modes", get(handlers::modes_mp))
|
||
|
|
.route("/{slug}/logout", get(login::logout))
|
||
|
|
.route("/{slug}/search", get(handlers::search_page_mp))
|
||
|
|
.route("/{slug}/assets/{*path}", get(handlers::serve_asset_mp))
|
||
|
|
.route("/{slug}/public/{*path}", get(handlers::serve_public_mp))
|
||
|
|
.route("/{slug}/backlog", get(handlers::backlog_page_mp))
|
||
|
|
.route(
|
||
|
|
"/{slug}/backlog/status",
|
||
|
|
post(handlers::backlog_update_status_mp),
|
||
|
|
)
|
||
|
|
.route("/{slug}/backlog/add", post(handlers::backlog_add_mp))
|
||
|
|
.route(
|
||
|
|
"/{slug}/notifications/{id}/action",
|
||
|
|
post(handlers::notification_action_mp),
|
||
|
|
)
|
||
|
|
.route(
|
||
|
|
"/{slug}/notifications/emit",
|
||
|
|
post(handlers::emit_notification_mp),
|
||
|
|
)
|
||
|
|
.route("/{slug}/compose", get(handlers::compose_page_mp))
|
||
|
|
.route(
|
||
|
|
"/{slug}/compose/form/{form_id}",
|
||
|
|
get(handlers::compose_form_schema_mp),
|
||
|
|
)
|
||
|
|
.route("/{slug}/compose/send", post(handlers::compose_send_mp))
|
||
|
|
.route("/{slug}/actions", get(handlers::actions_page_mp))
|
||
|
|
.route("/{slug}/actions/run", post(handlers::actions_run_mp))
|
||
|
|
.route("/{slug}/qa", get(handlers::qa_page_mp))
|
||
|
|
.route("/{slug}/qa/delete", post(handlers::qa_delete))
|
||
|
|
.route("/{slug}/qa/update", post(handlers::qa_update))
|
||
|
|
// Login is public — no AuthUser extractor
|
||
|
|
.route(
|
||
|
|
"/{slug}/login",
|
||
|
|
get(login::login_page).post(login::login_submit),
|
||
|
|
)
|
||
|
|
.with_state(state)
|
||
|
|
}
|