Compare commits

...

2 commits

Author SHA1 Message Date
6d0c2526c9 debug build cors rules 2024-07-05 11:44:57 +02:00
7945636b39 add dev cargo alias 2024-07-05 11:44:40 +02:00
5 changed files with 1357 additions and 1 deletions

2
.cargo/config.toml Normal file
View file

@ -0,0 +1,2 @@
[alias]
dev = "run -p backend"

1327
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,2 +1,3 @@
[workspace]
resolver = "2"
members = ["crates/backend"]

View file

@ -2,3 +2,7 @@
name = "backend"
version = "0.1.0"
edition = "2021"
[dependencies]
actix-web = "4"
actix-cors = "0.7"

View file

@ -1 +1,23 @@
fn main() {}
use actix_web::{web, App, HttpResponse, HttpServer, Responder};
#[actix_web::main]
async fn main() -> std::io::Result<()> {
#[cfg(debug_assertions)]
println!("Running debug build -> enabling permissive CORS");
HttpServer::new(move || {
let cors = if cfg!(debug_assertions) {
actix_cors::Cors::permissive()
} else {
actix_cors::Cors::default()
};
App::new().wrap(cors).route("/", web::get().to(index))
})
.bind(("127.0.0.1", 8080))?
.run()
.await
}
async fn index() -> impl Responder {
HttpResponse::Ok().body("API Test Response")
}