Initial project setup (rust)
This commit is contained in:
19
src/main.rs
Normal file
19
src/main.rs
Normal file
@@ -0,0 +1,19 @@
|
||||
use actix_web::{web, App, HttpServer, HttpResponse, get};
|
||||
use serde_json::json;
|
||||
|
||||
#[get("/")]
|
||||
async fn index() -> HttpResponse {
|
||||
HttpResponse::Ok().json(json!({"app": "test-rust2", "status": "running"}))
|
||||
}
|
||||
|
||||
#[get("/health")]
|
||||
async fn health() -> HttpResponse {
|
||||
HttpResponse::Ok().json(json!({"status": "ok"}))
|
||||
}
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
println!("test-rust2 running on port 8080");
|
||||
HttpServer::new(|| App::new().service(index).service(health))
|
||||
.bind("0.0.0.0:8080")?.run().await
|
||||
}
|
||||
Reference in New Issue
Block a user