1
Fork 0

flush endpoint

This commit is contained in:
Andy Killorin 2023-12-16 20:47:39 -06:00
parent 5b5ce1995a
commit 3041858b99
Signed by: ank
GPG key ID: B6241CA3B552BCA4

View file

@ -101,6 +101,7 @@ async fn main() -> Result<(), Error> {
.route("/turtle/new", post(create_turtle)) .route("/turtle/new", post(create_turtle))
.route("/turtle/update/:id", post(command)) .route("/turtle/update/:id", post(command))
.route("/turtle/client.lua", get(client)) .route("/turtle/client.lua", get(client))
.route("/flush", get(flush))
.with_state(state.clone()); .with_state(state.clone());
let listener = tokio::net::TcpListener::bind("0.0.0.0:48228").await.unwrap(); let listener = tokio::net::TcpListener::bind("0.0.0.0:48228").await.unwrap();
@ -163,6 +164,12 @@ async fn write_to_disk(state: SharedControl) -> anyhow::Result<()> {
Ok(()) Ok(())
} }
async fn flush(State(state): State<SharedControl>) -> &'static str {
write_to_disk(state).await.unwrap();
"ACK"
}
async fn shutdown_signal() { async fn shutdown_signal() {
let ctrl_c = async { let ctrl_c = async {
signal::ctrl_c() signal::ctrl_c()