Skip to content

Commit f01b71c

Browse files
add health check
1 parent aa7e910 commit f01b71c

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/server/handle_request.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ pub async fn handle_request(req: Request<Body>) -> Result<Response<Body>, hyper:
1818
match (req.method(), req.uri().path()) {
1919
(&hyper::Method::GET, "/") => handle_default_path(),
2020

21+
(&hyper::Method::GET, "/health") => handle_health_path(),
22+
2123
(&hyper::Method::GET, path) if path.starts_with("/.well-known/lnurlp/") => {
2224
handle_invoice_path(path, req.uri()).await
2325
}
@@ -43,6 +45,17 @@ struct DefaultPathResponse {
4345
info: Info,
4446
}
4547

48+
fn handle_health_path() -> Result<Response<Body>, hyper::Error> {
49+
let response_body = json!({
50+
"status": "OK"
51+
});
52+
53+
let response_body_string =
54+
serde_json::to_string(&response_body).expect("Failed to serialize response body to JSON");
55+
56+
handle_ok_request(response_body_string)
57+
}
58+
4659
fn handle_default_path() -> Result<Response<Body>, hyper::Error> {
4760
let (domain, username) = get_identifiers();
4861

0 commit comments

Comments
 (0)