2021-04-16 00:32:03 +02:00
|
|
|
#![feature(proc_macro_hygiene, decl_macro)]
|
|
|
|
|
2021-04-02 21:20:36 +02:00
|
|
|
#[macro_use]
|
|
|
|
extern crate rocket;
|
2021-04-16 00:32:03 +02:00
|
|
|
mod catchers;
|
|
|
|
mod routes;
|
2021-03-06 00:25:40 +01:00
|
|
|
|
2021-04-14 22:00:56 +02:00
|
|
|
// Very temporary solution for CORS
|
|
|
|
// https://stackoverflow.com/questions/62412361/how-to-set-up-cors-or-options-for-rocket-rs
|
|
|
|
use rocket::fairing::{Fairing, Info, Kind};
|
|
|
|
use rocket::http::Header;
|
|
|
|
use rocket::{Request, Response};
|
|
|
|
|
|
|
|
pub struct CORS;
|
|
|
|
|
|
|
|
impl Fairing for CORS {
|
|
|
|
fn info(&self) -> Info {
|
|
|
|
Info {
|
|
|
|
name: "Add CORS headers to responses",
|
|
|
|
kind: Kind::Response,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn on_response(&self, _: &Request, response: &mut Response) {
|
|
|
|
response.set_header(Header::new("Access-Control-Allow-Origin", "*"));
|
|
|
|
response.set_header(Header::new(
|
|
|
|
"Access-Control-Allow-Methods",
|
|
|
|
"POST, GET, PATCH, OPTIONS",
|
|
|
|
));
|
|
|
|
response.set_header(Header::new("Access-Control-Allow-Headers", "*"));
|
|
|
|
response.set_header(Header::new("Access-Control-Allow-Credentials", "true"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-06 00:25:40 +01:00
|
|
|
fn rocket() -> rocket::Rocket {
|
|
|
|
rocket::ignite()
|
2021-04-14 22:00:56 +02:00
|
|
|
.attach(CORS)
|
2021-04-16 00:32:03 +02:00
|
|
|
.mount("/ivago", routes::ivago())
|
2021-04-04 15:13:36 +02:00
|
|
|
.register(catchers![catchers::not_found])
|
2021-03-06 00:25:40 +01:00
|
|
|
}
|
2021-03-05 18:55:18 +01:00
|
|
|
|
2021-03-05 18:39:49 +01:00
|
|
|
fn main() {
|
2021-03-06 00:25:40 +01:00
|
|
|
rocket().launch();
|
2021-03-05 18:39:49 +01:00
|
|
|
}
|