-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
consume db client through server router
- Loading branch information
Showing
3 changed files
with
18 additions
and
3 deletions.
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
Empty file.
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 |
---|---|---|
@@ -1,10 +1,16 @@ | ||
use std::sync::Mutex; | ||
|
||
use actix_web::{get, HttpResponse, Responder}; | ||
|
||
pub mod application; | ||
pub mod blockchain; | ||
|
||
/// Return server health status | ||
#[get("/health")] | ||
pub async fn health() -> impl Responder { | ||
HttpResponse::Ok().body("OK") | ||
pub async fn health(client: actix_web::web::Data<Mutex<mongodb::Client>>) -> impl Responder { | ||
let client = client.lock().unwrap(); | ||
match crate::db::setup::db_health_check(client.clone()).await { | ||
Ok(_) => HttpResponse::Ok().body("OK"), | ||
Err(e) => HttpResponse::InternalServerError().body(format!("Error: {}", e)), | ||
} | ||
} |