Add rust web server

This commit is contained in:
Reimar 2024-08-13 13:57:14 +02:00
parent c1a5425127
commit f086982037
Signed by: Reimar
GPG Key ID: 93549FA07F0AE268
4 changed files with 1307 additions and 0 deletions

2
rust-backend/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
target

1275
rust-backend/Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

8
rust-backend/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "skantravels"
version = "0.1.0"
edition = "2021"
[dependencies]
actix-web = "4"

22
rust-backend/src/main.rs Normal file
View File

@ -0,0 +1,22 @@
use actix_web::{get, Responder, HttpResponse, HttpServer, App};
#[get("/hc")]
async fn healthcheck() -> impl Responder {
HttpResponse::Ok().body("OK")
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let port = std::env::var("RUST_BACKEND_PORT")
.ok()
.and_then(|port| port.parse::<u16>().ok())
.unwrap_or(8080);
HttpServer::new(|| {
App::new()
.service(healthcheck)
})
.bind(("127.0.0.1", port))?
.run()
.await
}