-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add /healthz healthcheck endpoint (#20)
It merely returns "OK" with a 200 status code
- Loading branch information
1 parent
c9ee009
commit 611a483
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use crate::http::{ok, Request, Result}; | ||
|
||
pub async fn healthz(_req: Request) -> Result { | ||
ok("OK") | ||
} | ||
|
||
#[cfg(test)] | ||
mod test { | ||
use super::*; | ||
use crate::test::*; | ||
use hyper::http::StatusCode; | ||
|
||
#[tokio::test] | ||
async fn test_healthz() { | ||
let res = request().handle(healthz).await.unwrap(); | ||
|
||
assert_eq!(res.status(), StatusCode::OK); | ||
let body = res.read_body_utf8().await.unwrap(); | ||
assert_eq!(body, "OK"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters