23 lines
623 B
Rust
23 lines
623 B
Rust
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")
|
|
}
|