2021-10-03 11:13:07 +02:00
|
|
|
#[macro_use]
|
|
|
|
extern crate rocket;
|
|
|
|
|
|
|
|
#[macro_use]
|
|
|
|
extern crate serde_with;
|
|
|
|
|
|
|
|
pub mod empty;
|
|
|
|
pub mod garbage;
|
|
|
|
pub mod get_ip;
|
2021-10-03 16:57:12 +02:00
|
|
|
pub mod haversine;
|
2021-10-03 11:13:07 +02:00
|
|
|
pub mod serialized_ip_info;
|
|
|
|
pub mod util;
|
|
|
|
|
|
|
|
use dotenv::dotenv;
|
|
|
|
use std::error::Error;
|
|
|
|
|
2021-10-04 14:05:22 +02:00
|
|
|
use rocket::fs::FileServer;
|
2021-10-03 11:13:07 +02:00
|
|
|
use rocket::http::Method;
|
|
|
|
|
|
|
|
use empty::*;
|
|
|
|
use garbage::*;
|
|
|
|
use get_ip::*;
|
|
|
|
|
|
|
|
#[rocket::main]
|
|
|
|
async fn main() -> Result<(), Box<dyn Error>> {
|
|
|
|
dotenv().ok();
|
|
|
|
|
|
|
|
let routes = routes![get_ip::get_ip, get_backend_ip_php];
|
|
|
|
|
|
|
|
let garbage_routes = routes![
|
|
|
|
garbage::garbage,
|
|
|
|
garbage_php,
|
|
|
|
backend_garbage,
|
|
|
|
backend_garbage_php
|
|
|
|
];
|
|
|
|
|
|
|
|
let empty_routes = routes![
|
|
|
|
empty::empty,
|
|
|
|
backend_empty,
|
|
|
|
get_empty,
|
|
|
|
empty_php,
|
|
|
|
backend_empty_php,
|
|
|
|
get_backend_empty_php
|
|
|
|
];
|
|
|
|
|
2021-10-03 16:57:12 +02:00
|
|
|
let routes = vec![routes, garbage_routes, empty_routes].concat();
|
|
|
|
|
2022-10-10 21:17:24 +02:00
|
|
|
let mut rocketship = rocket::build().mount("/", routes);
|
2021-10-03 16:57:12 +02:00
|
|
|
|
2021-10-04 14:05:22 +02:00
|
|
|
let asset_path = std::env::current_dir().unwrap().join("assets");
|
|
|
|
if asset_path.exists() {
|
2021-10-03 11:13:07 +02:00
|
|
|
let fileserver = FileServer::from(asset_path);
|
|
|
|
|
2021-10-03 16:57:12 +02:00
|
|
|
rocketship = rocketship.mount("/", fileserver);
|
2021-10-03 11:13:07 +02:00
|
|
|
}
|
|
|
|
|
2021-10-03 16:57:12 +02:00
|
|
|
rocketship.launch().await?;
|
|
|
|
|
2021-10-03 11:13:07 +02:00
|
|
|
Ok(())
|
|
|
|
}
|