Skip to content

Commit

Permalink
web: Add endpoint for mavlink2rest rest endpoint
Browse files Browse the repository at this point in the history
Signed-off-by: Patrick José Pereira <[email protected]>
  • Loading branch information
patrickelectric committed Oct 2, 2024
1 parent c660971 commit e16cecd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/web/endpoints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ pub async fn info() -> Json<Info> {

Json(info)
}

pub async fn mavlink(path: Option<Path<String>>) -> impl IntoResponse {
let path = match path {
Some(path) => path.0.to_string(),
None => String::default(),
};
crate::drivers::rest::data::messages(&path)
}
4 changes: 4 additions & 0 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit e16cecd

Please sign in to comment.