Created
October 12, 2021 18:02
-
-
Save tjmaynes/1fe804278dcbf2c09e4c64520121b421 to your computer and use it in GitHub Desktop.
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
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