Skip to content

Commit

Permalink
Add health check endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Mulder90 committed Feb 10, 2024
1 parent d07a5c3 commit e2cde99
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
use actix_web::{web, App, HttpRequest, HttpServer, Responder};
use actix_web::{web, App, HttpResponse, HttpServer, Responder};

async fn greet(req: HttpRequest) -> impl Responder {
let name = req.match_info().get("name").unwrap_or("World");
format!("Hello {}!", &name)
async fn health_check() -> impl Responder {
HttpResponse::Ok()
}

#[tokio::main]
async fn main() -> Result<(), std::io::Error> {
HttpServer::new(|| {
App::new()
.route("/", web::get().to(greet))
.route("/{name}", web::get().to(greet))
})
.bind("127.0.0.1:8000")?
.run()
.await
HttpServer::new(|| App::new().route("/health_check", web::get().to(health_check)))
.bind("127.0.0.1:8000")?
.run()
.await
}

0 comments on commit e2cde99

Please sign in to comment.