diff --git a/src/web/endpoints.rs b/src/web/endpoints.rs index 1c7949d1..1fb9bf54 100644 --- a/src/web/endpoints.rs +++ b/src/web/endpoints.rs @@ -59,3 +59,11 @@ pub async fn info() -> Json { Json(info) } + +pub async fn mavlink(path: Option>) -> impl IntoResponse { + let path = match path { + Some(path) => path.0.to_string(), + None => String::default(), + }; + crate::drivers::rest::data::messages().pointer(&path) +} diff --git a/src/web/mod.rs b/src/web/mod.rs index 37def49d..1b1d6658 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -27,6 +27,10 @@ fn default_router(state: AppState) -> Router { .route("/:path", get(endpoints::root)) .route("/info", get(endpoints::info)) .route("/rest/ws", get(websocket_handler)) + // We are matching all possible keys for the user + .route("/rest/mavlink", get(endpoints::mavlink)) + .route("/rest/mavlink/", get(endpoints::mavlink)) + .route("/rest/mavlink/*path", get(endpoints::mavlink)) .fallback(get(|| async { (StatusCode::NOT_FOUND, "Not found :(") })) .with_state(state) }