forked from ReiMerc/skantravels
Add rust web server
This commit is contained in:
parent
6ba8ed7ce0
commit
4cac32b55c
2
rust-backend/.gitignore
vendored
Normal file
2
rust-backend/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
target
|
||||||
|
|
1275
rust-backend/Cargo.lock
generated
Normal file
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
8
rust-backend/Cargo.toml
Normal 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
22
rust-backend/src/main.rs
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user