Skip to content

Commit

Permalink
fix: Correct wrong GET http method usage in example code (#147)
Browse files Browse the repository at this point in the history
* fix: Correct GET method usage in example code #120

* chore: Update raft-rs

---------

Co-authored-by: JJangcoding <bymyself103@naver.com>
Co-authored-by: Gyubong <jopemachine@naver.com>
  • Loading branch information
3 people authored Oct 5, 2024
1 parent 65214a0 commit eab69cb
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions examples/memstore/src/web_server_api.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::HashMap;

use actix_web::{get, put, web, HttpResponse, Responder};
use actix_web::{get, post, put, web, HttpResponse, Responder};
use raftify::{raft::Storage, AbstractLogEntry, StableStorage};
use serde_json::Value;

Expand Down Expand Up @@ -39,7 +39,7 @@ async fn leader(data: web::Data<(HashStore, Raft)>) -> impl Responder {
format!("{:?}", leader_id)
}

#[get("/leave")]
#[post("/leave")]
async fn leave(data: web::Data<(HashStore, Raft)>) -> impl Responder {
let raft = data.clone();
raft.1.leave().await.unwrap();
Expand All @@ -61,7 +61,7 @@ async fn peers(data: web::Data<(HashStore, Raft)>) -> impl Responder {
format!("{:?}", peers)
}

#[get("/snapshot")]
#[post("/snapshot")]
async fn snapshot(data: web::Data<(HashStore, Raft)>) -> impl Responder {
#[cfg(feature = "inmemory_storage")]
{
Expand Down Expand Up @@ -95,14 +95,14 @@ async fn snapshot(data: web::Data<(HashStore, Raft)>) -> impl Responder {
}
}

#[get("/leave_joint")]
#[post("/leave_joint")]
async fn leave_joint(data: web::Data<(HashStore, Raft)>) -> impl Responder {
let raft = data.clone();
raft.1.leave_joint().await;
"OK".to_string()
}

#[get("/transfer_leader/{id}")]
#[post("/transfer_leader/{id}")]
async fn transfer_leader(
data: web::Data<(HashStore, Raft)>,
path: web::Path<u64>,
Expand All @@ -113,14 +113,14 @@ async fn transfer_leader(
"OK".to_string()
}

#[get("/campaign")]
#[post("/campaign")]
async fn campaign(data: web::Data<(HashStore, Raft)>) -> impl Responder {
let raft = data.clone();
raft.1.campaign().await.unwrap();
"OK".to_string()
}

#[get("/demote/{term}/{leader_id}")]
#[post("/demote/{term}/{leader_id}")]
async fn demote(data: web::Data<(HashStore, Raft)>, path: web::Path<(u64, u64)>) -> impl Responder {
let raft = data.clone();
let (term, leader_id) = path.into_inner();
Expand Down

0 comments on commit eab69cb

Please sign in to comment.