2025-09-14 16:19:44 -04:00
|
|
|
use axum::{
|
|
|
|
|
Router,
|
2025-09-25 14:51:09 -07:00
|
|
|
extract::{Path, State},
|
2025-09-14 16:19:44 -04:00
|
|
|
response::Redirect,
|
|
|
|
|
routing::{get, post},
|
|
|
|
|
};
|
|
|
|
|
use axum_extra::routing::RouterExt as _;
|
2025-09-25 14:51:09 -07:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
use uuid::Uuid;
|
2025-09-14 16:19:44 -04:00
|
|
|
|
2025-09-25 14:51:09 -07:00
|
|
|
use crate::{Settings, app::App};
|
2025-09-14 16:19:44 -04:00
|
|
|
|
|
|
|
|
use super::relations_single;
|
|
|
|
|
|
2025-11-01 00:17:07 +00:00
|
|
|
mod add_service_credential_handler;
|
2025-09-14 16:19:44 -04:00
|
|
|
mod add_table_handler;
|
|
|
|
|
mod nav_handler;
|
2025-11-01 00:17:07 +00:00
|
|
|
mod service_credentials_handler;
|
2025-09-14 16:19:44 -04:00
|
|
|
|
2025-09-25 14:51:09 -07:00
|
|
|
#[derive(Clone, Debug, Deserialize)]
|
|
|
|
|
struct PathParams {
|
|
|
|
|
workspace_id: Uuid,
|
|
|
|
|
}
|
|
|
|
|
|
2025-09-14 16:19:44 -04:00
|
|
|
pub(super) fn new_router() -> Router<App> {
|
|
|
|
|
Router::<App>::new()
|
2025-09-25 14:51:09 -07:00
|
|
|
.route_with_tsr(
|
|
|
|
|
"/{workspace_id}",
|
|
|
|
|
get(
|
|
|
|
|
|State(Settings { root_path, .. }): State<Settings>,
|
|
|
|
|
Path(PathParams { workspace_id }): Path<PathParams>| async move {
|
|
|
|
|
Redirect::to(&format!(
|
|
|
|
|
"{root_path}/w/{workspace_id}/nav/",
|
|
|
|
|
workspace_id = workspace_id.simple()
|
|
|
|
|
))
|
|
|
|
|
},
|
|
|
|
|
),
|
|
|
|
|
)
|
2025-11-01 00:17:07 +00:00
|
|
|
.route(
|
|
|
|
|
"/{workspace_id}/add-service-credential",
|
|
|
|
|
post(add_service_credential_handler::post),
|
|
|
|
|
)
|
2025-09-25 14:51:09 -07:00
|
|
|
.route("/{workspace_id}/add-table", post(add_table_handler::post))
|
|
|
|
|
.route_with_tsr("/{workspace_id}/nav/", get(nav_handler::get))
|
2025-11-01 00:17:07 +00:00
|
|
|
.route_with_tsr(
|
|
|
|
|
"/{workspace_id}/service-credentials",
|
|
|
|
|
get(service_credentials_handler::get),
|
|
|
|
|
)
|
2025-09-25 14:51:09 -07:00
|
|
|
.nest(
|
|
|
|
|
"/{workspace_id}/r/{rel_oid}",
|
|
|
|
|
relations_single::new_router(),
|
|
|
|
|
)
|
2025-09-14 16:19:44 -04:00
|
|
|
}
|