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) { 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; }