phonograph/interim-server/src/routes/workspaces_single/mod.rs

54 lines
1.5 KiB
Rust
Raw Normal View History

use axum::{
Router,
2025-09-25 14:51:09 -07:00
extract::{Path, State},
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-25 14:51:09 -07:00
use crate::{Settings, app::App};
use super::relations_single;
mod add_service_credential_handler;
mod add_table_handler;
mod nav_handler;
mod service_credentials_handler;
2025-09-25 14:51:09 -07:00
#[derive(Clone, Debug, Deserialize)]
struct PathParams {
workspace_id: Uuid,
}
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()
))
},
),
)
.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))
.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(),
)
}