Skip to content

Commit

Permalink
add /ping as health API
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Jan 25, 2024
1 parent fb1470b commit 736fb19
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions rpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ impl RpcServer {
let mut app = Router::new()
.route("/", method_router.clone())
.route("/*path", method_router)
.route("/ping", get(ping_handler))
.layer(Extension(Arc::clone(rpc)))
.layer(CorsLayer::permissive())
.layer(TimeoutLayer::new(Duration::from_secs(30)))
Expand Down Expand Up @@ -189,6 +190,11 @@ impl RpcServer {
}
}

/// used for compatible with old health endpoint
async fn ping_handler() -> impl IntoResponse {
"pong"
}

/// used for compatible with old PRC error responce for GET
async fn get_error_handler() -> impl IntoResponse {
(
Expand Down

0 comments on commit 736fb19

Please sign in to comment.