use actix_web::post; use actix_web::web; use actix_web::web::Data; use actix_web::Responder; use openraft::error::CheckIsLeaderError; use openraft::error::Infallible; use openraft::error::RaftError; use openraft::BasicNode; use web::Json; use crate::app::ExampleApp; use crate::store::ExampleRequest; use crate::ExampleNodeId; /** * Application API * * This is where you place your application, you can use the example below to create your * API. The current implementation: * * - `POST - /write` saves a value in a key and sync the nodes. * - `POST - /read` attempt to find a value from a given key. */ #[post("/write")] pub async fn write( app: Data, req: Json, ) -> actix_web::Result { let response = app.raft.client_write(req.0).await; Ok(Json(response)) } // AddVisitor(AddVisitor), // AddCaptcha(AddCaptcha), // RenameCaptcha(RenameCaptcha), // RemoveCaptcha(RemoveCaptcha), //#[post("/post")] //pub async fn read(app: Data, req: Json) -> actix_web::Result { // let state_machine = app.store.state_machine.read().await; // let key = req.0; // let value = state_machine.data.get(&key).cloned(); // // let res: Result = Ok(value.unwrap_or_default()); // Ok(Json(res)) //} // //#[post("/visitor/add")] //pub async fn add_visitor(app: Data, req: Json) -> actix_web::Result { // let state_machine = app.store.state_machine.read().await; // let key = req.0; // let value = state_machine.data.get(&key).cloned(); // // let res: Result = Ok(value.unwrap_or_default()); // Ok(Json(res)) //}