Compare commits
2 commits
9bfe6ded8f
...
6d0c2526c9
Author | SHA1 | Date | |
---|---|---|---|
6d0c2526c9 | |||
7945636b39 |
5 changed files with 1357 additions and 1 deletions
2
.cargo/config.toml
Normal file
2
.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
[alias]
|
||||
dev = "run -p backend"
|
1327
Cargo.lock
generated
1327
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -1,2 +1,3 @@
|
|||
[workspace]
|
||||
resolver = "2"
|
||||
members = ["crates/backend"]
|
||||
|
|
|
@ -2,3 +2,7 @@
|
|||
name = "backend"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
actix-web = "4"
|
||||
actix-cors = "0.7"
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue