turtle info endpoint
This commit is contained in:
parent
721ffeb765
commit
3f5a258ea9
1 changed files with 13 additions and 3 deletions
|
@ -63,7 +63,7 @@ impl Direction {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
#[derive(Serialize, Deserialize, Clone)]
|
||||
struct Turtle {
|
||||
name: Name,
|
||||
fuel: usize,
|
||||
|
@ -111,9 +111,10 @@ async fn main() -> Result<(), Error> {
|
|||
.route("/turtle/new", post(create_turtle))
|
||||
.route("/turtle/update/:id", post(command))
|
||||
.route("/turtle/client.lua", get(client))
|
||||
.route("/turtle/control/:id/setGoal", post(set_goal))
|
||||
.route("/turtle/setGoal/:id", post(set_goal))
|
||||
.route("/turtle/info/:id", get(turtle_info))
|
||||
.route("/turtle/updateAll", get(update_turtles))
|
||||
.route("/flush", get(flush))
|
||||
.route("/updateTurtles", get(update_turtles))
|
||||
.with_state(state.clone());
|
||||
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:48228").await.unwrap();
|
||||
|
@ -221,6 +222,15 @@ async fn update_turtles(
|
|||
"ACK"
|
||||
}
|
||||
|
||||
async fn turtle_info(
|
||||
Path(id): Path<u32>,
|
||||
State(state): State<SharedControl>,
|
||||
) -> Json<Turtle> {
|
||||
let state = &mut state.read().await;
|
||||
|
||||
Json(state.turtles[id as usize].clone())
|
||||
}
|
||||
|
||||
async fn command(
|
||||
Path(id): Path<u32>,
|
||||
State(state): State<SharedControl>,
|
||||
|
|
Loading…
Reference in a new issue