got api working ish, I need to clean this code up a lot

This commit is contained in:
2026-04-27 17:26:49 +01:00
parent c87949bc4b
commit c53138b163
13 changed files with 1143 additions and 43 deletions
+36
View File
@@ -0,0 +1,36 @@
use warp::Filter;
use std::{
thread,
sync::{Arc, Mutex},
}
use crate::config;
use serde::{Deserialize, Serialize};
use crate::mpsc::*;
use tokio::sync::RwLock;
use crate::api;
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Data_to_send {
pub action_type: String,
pub content: String,
pub character: String,
}
#[derive(Debug, Deserialize, Serialize, Clone)]
pub struct Data_to_receive {
pub response: String,
}
pub async fn api_process(data_to_send: Arc<api::Data_to_send>)
{
let route = warp::path("happening")
.map({
let state = Arc::clone(&data_to_send);
move || {
let current_data = state.lock().unwrap().clone();
warp::reply::json(current_data)
}
});
warp::serve(routes)
.run(([127, 0, 0, 1],config::API_PORT));
.await;
}