2021-07-17 23:41:41 +00:00
|
|
|
#[macro_use] extern crate log;
|
2021-07-16 14:55:07 +00:00
|
|
|
#[macro_use] extern crate rocket;
|
2021-07-17 23:41:41 +00:00
|
|
|
#[macro_use] extern crate rocket_contrib;
|
|
|
|
|
2021-07-17 11:57:40 +00:00
|
|
|
use rocket::fairing::AdHoc;
|
2021-07-17 18:45:52 +00:00
|
|
|
|
2021-07-17 15:40:05 +00:00
|
|
|
mod auth;
|
2021-07-17 18:45:52 +00:00
|
|
|
mod user;
|
|
|
|
mod message;
|
2021-07-17 19:53:10 +00:00
|
|
|
mod file_io;
|
2021-07-17 23:41:41 +00:00
|
|
|
mod chat;
|
2021-07-16 14:55:07 +00:00
|
|
|
|
|
|
|
#[launch]
|
|
|
|
fn rocket() -> _ {
|
2021-07-17 18:45:52 +00:00
|
|
|
env_logger::init();
|
|
|
|
info!("Started up rocket");
|
2021-07-17 11:57:40 +00:00
|
|
|
let cors_fairing = AdHoc::on_response("CORS", |_, res| {
|
|
|
|
Box::pin(async move {
|
|
|
|
res.set_raw_header("Access-Control-Allow-Origin", "*");
|
|
|
|
})
|
|
|
|
});
|
2021-07-17 18:45:52 +00:00
|
|
|
info!("Built CORS fairing");
|
2021-07-17 11:57:40 +00:00
|
|
|
|
|
|
|
rocket::build()
|
|
|
|
.mount(
|
|
|
|
"/",
|
2021-07-17 23:41:41 +00:00
|
|
|
routes![auth::index, auth::get_user, auth::register_user, auth::check_pin, auth::change, auth::get_user_name, auth::get_user_pronouns, chat::send_message],
|
2021-07-17 11:57:40 +00:00
|
|
|
)
|
|
|
|
.attach(cors_fairing)
|
2021-07-16 14:55:07 +00:00
|
|
|
}
|