Skip to content

Instantly share code, notes, and snippets.

@tjmaynes
Created October 12, 2021 18:02
Show Gist options
  • Save tjmaynes/1fe804278dcbf2c09e4c64520121b421 to your computer and use it in GitHub Desktop.
Save tjmaynes/1fe804278dcbf2c09e4c64520121b421 to your computer and use it in GitHub Desktop.
use actix_web::{web, App, HttpServer, HttpResponse};
async fn get_health_status() -> HttpResponse {
HttpResponse::Ok()
.content_type("application/json")
.body("Healthy!")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
HttpServer::new(|| {
App::new()
.route("/health", web::get().to(get_health_status))
// ^ Our new health route points to the get_health_status handler
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment