Skip to content

Commit

Permalink
refactor: fix middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
tchataigner committed Sep 13, 2024
1 parent 9d381dd commit e25156a
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions aptos/proof-server/src/bin/proof_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -422,18 +422,18 @@ async fn count_requests_middleware(
req: axum::http::Request<Body>,
next: Next,
) -> Result<impl IntoResponse, StatusCode> {
let is_health = req.uri().path() != "/health";
// Check if the request is for the health endpoint.
if is_health {
let is_ready = req.uri().path() != "/ready";
// Check if the request is for the ready endpoint.
if is_ready {
// Increment the active requests counter.
state.active_requests.fetch_add(1, Ordering::SeqCst);
}

// Proceed with the request.
let response = next.run(req).await;

// Decrement the active requests counter if not a health check.
if is_health {
// Decrement the active requests counter if not a ready check.
if is_ready {
state.active_requests.fetch_sub(1, Ordering::SeqCst);
}

Expand Down
12 changes: 6 additions & 6 deletions ethereum/light-client/src/bin/proof_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,19 +308,19 @@ async fn count_requests_middleware(
State(state): State<ServerState>,
req: axum::http::Request<Body>,
next: Next,
) -> Result<impl IntoResponse, StatusCode> {
let is_health = req.uri().path() != "/health";
// Check if the request is for the health endpoint.
if is_health {
) -> std::result::Result<impl IntoResponse, StatusCode> {
let is_ready = req.uri().path() != "/ready";
// Check if the request is for the ready endpoint.
if is_ready {
// Increment the active requests counter.
state.active_requests.fetch_add(1, Ordering::SeqCst);
}

// Proceed with the request.
let response = next.run(req).await;

// Decrement the active requests counter if not a health check.
if is_health {
// Decrement the active requests counter if not a ready check.
if is_ready {
state.active_requests.fetch_sub(1, Ordering::SeqCst);
}

Expand Down
12 changes: 6 additions & 6 deletions kadena/light-client/src/bin/proof_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,19 +116,19 @@ async fn count_requests_middleware(
State(state): State<ServerState>,
req: axum::http::Request<Body>,
next: Next,
) -> Result<impl IntoResponse, StatusCode> {
let is_health = req.uri().path() != "/health";
// Check if the request is for the health endpoint.
if is_health {
) -> std::result::Result<impl IntoResponse, StatusCode> {
let is_ready = req.uri().path() != "/ready";
// Check if the request is for the ready endpoint.
if is_ready {
// Increment the active requests counter.
state.active_requests.fetch_add(1, Ordering::SeqCst);
}

// Proceed with the request.
let response = next.run(req).await;

// Decrement the active requests counter if not a health check.
if is_health {
// Decrement the active requests counter if not a ready check.
if is_ready {
state.active_requests.fetch_sub(1, Ordering::SeqCst);
}

Expand Down

0 comments on commit e25156a

Please sign in to comment.