From 3655d61ca201b20fcb5e4fa0192ddcafbf6f7628 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 6 May 2021 17:33:46 +0000 Subject: feat(global): :star: --- src/main.rs | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'src/main.rs') 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 } -- cgit v1.2.3