lila-chat/src/main.rs

46 lines
1.0 KiB
Rust
Raw Normal View History

#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate rocket;
#[macro_use]
extern crate rocket_contrib;
2021-07-18 17:16:00 +00:00
use rocket_contrib::serve::StaticFiles;
2021-07-17 23:41:41 +00:00
use rocket::fairing::AdHoc;
mod auth;
2021-07-17 23:41:41 +00:00
mod chat;
mod file_io;
mod message;
mod user;
fn main() {
env_logger::init();
info!("Started up rocket");
let cors_fairing = AdHoc::on_response("CORS", |_, res| {
2021-07-22 18:23:59 +00:00
res.set_raw_header("Access-Control-Allow-Origin", "http://localhost:8000");
});
info!("Built CORS fairing");
rocket::ignite()
.mount(
2021-07-18 17:16:00 +00:00
"/api",
routes![
auth::get_user,
auth::register_user,
2021-07-23 13:48:57 +00:00
auth::login,
2021-07-18 15:37:11 +00:00
chat::send_message,
2021-07-18 20:36:23 +00:00
chat::fetch_messages,
auth::change_info,
2021-07-22 18:23:59 +00:00
auth::check_token,
auth::logout,
auth::moderation_actions
],
)
2021-07-18 17:16:00 +00:00
.mount("/", StaticFiles::from("frontend"))
.attach(cors_fairing)
.launch();
}