diff options
| author | Fuwn <[email protected]> | 2021-05-06 17:33:46 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-06 17:33:46 -0700 |
| commit | ba5cf895d7213efed871dd23a37622454dc228d1 (patch) | |
| tree | b70e2faf16e1c221aff44bf143a67ca3a361deae /src/main.rs | |
| parent | etc: Remove useless CORS headers (diff) | |
| download | api-ba5cf895d7213efed871dd23a37622454dc228d1.tar.xz api-ba5cf895d7213efed871dd23a37622454dc228d1.zip | |
feat(global): :star:
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs index 50e4d9b..18f56fc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,27 +1,36 @@ // Copyleft (ɔ) 2021-2021 The Senpy Club // SPDX-License-Identifier: GPL-3.0-only -#![feature(proc_macro_hygiene, decl_macro, type_ascription)] +#![feature(type_ascription)] #[macro_use] -extern crate rocket; +extern crate actix_web; pub mod constants; pub mod routes; pub mod structures; pub mod utils; -#[launch] -fn rocket() -> _ { +#[actix_web::main] +async fn main() -> std::io::Result<()> { dotenv::dotenv().ok(); - rocket::build().mount("/", routes![routes::index]).mount( - "/api/v1", - routes![ - routes::github, - routes::languages, - routes::language, - routes::random - ], - ) + actix_web::HttpServer::new(|| { + actix_web::App::new() + .wrap(actix_cors::Cors::default().allow_any_origin()) + .service(routes::index) + .service( + actix_web::web::scope("/api/v1") + .service(routes::github) + .service(routes::languages) + .service(routes::language) + .service(routes::random), + ) + }) + .bind(format!( + "0.0.0.0:{}", + std::env::var("PORT").expect("no port was provided... ~why~") + ))? + .run() + .await } |