Skip to content

Commit

Permalink
Update trailing slash routes for axum 0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
rufusutt committed Aug 30, 2023
1 parent 4d114dc commit cfd4e94
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions node/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ rust-version = "1.56"
[dependencies]
async-trait = "0.1"
axum = { version = "0.6", default-features = false, features = ["http1", "json", "original-uri", "tower-log", "tokio"] }
axum-extra = { version = "0.7" }
futures = "0.3"
nmos-model = { path = "../model" }
nmos-schema = { path = "../schema" }
Expand Down
21 changes: 11 additions & 10 deletions node/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use axum::{
body::Body, extract::OriginalUri, http::Request, http::StatusCode, response::Response,
routing::get, Extension, Json, Router,
};
use axum_extra::routing::RouterExt;
use error::ServiceError;
use futures::Future;
use nmos_model::Model;
Expand All @@ -38,10 +39,10 @@ impl NodeApi {
"/",
get(|| async { Json(json!(["x-manifest/", "x-nmos/"])) }),
)
.route("/x-nmos/", get(|| async { Json(json!(["node/"])) }))
.route("/x-nmos/node/", get(|| async { Json(json!(["v1.0/"])) }))
.route(
"/x-nmos/node/v1.0/",
.route_with_tsr("/x-nmos", get(|| async { Json(json!(["node/"])) }))
.route_with_tsr("/x-nmos/node", get(|| async { Json(json!(["v1.0/"])) }))
.route_with_tsr(
"/x-nmos/node/v1.0",
get(|| async {
Json(json!([
"devices/",
Expand All @@ -53,16 +54,16 @@ impl NodeApi {
]))
}),
)
.route("/x-nmos/node/:api/self", get(get_self))
.route("/x-nmos/node/:api/devices/", get(get_devices))
.route_with_tsr("/x-nmos/node/:api/self", get(get_self))
.route_with_tsr("/x-nmos/node/:api/devices", get(get_devices))
.route("/x-nmos/node/:api/devices/:id", get(get_device))
.route("/x-nmos/node/:api/receivers/", get(get_receivers))
.route_with_tsr("/x-nmos/node/:api/receivers", get(get_receivers))
.route("/x-nmos/node/:api/receivers/:id", get(get_receiver))
.route("/x-nmos/node/:api/senders/", get(get_senders))
.route_with_tsr("/x-nmos/node/:api/senders", get(get_senders))
.route("/x-nmos/node/:api/senders/:id", get(get_sender))
.route("/x-nmos/node/:api/sources/", get(get_sources))
.route_with_tsr("/x-nmos/node/:api/sources", get(get_sources))
.route("/x-nmos/node/:api/sources/:id", get(get_source))
.route("/x-nmos/node/:api/flows/", get(get_flows))
.route_with_tsr("/x-nmos/node/:api/flows", get(get_flows))
.route("/x-nmos/node/:api/flows/:id", get(get_flow))
.fallback(fallback_handler)
.layer(Extension(model));
Expand Down

0 comments on commit cfd4e94

Please sign in to comment.