Add rust web server

This commit is contained in:
Reimar 2024-08-13 13:57:14 +02:00
parent 6ba8ed7ce0
commit 4cac32b55c
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
}