[#24] Added db connection to server
parent
5746d29556
commit
3a490fca35
|
@ -2,6 +2,8 @@
|
|||
|
||||
#[macro_use]
|
||||
extern crate rocket;
|
||||
#[macro_use]
|
||||
extern crate rocket_contrib;
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests;
|
||||
|
@ -14,6 +16,7 @@ mod routes;
|
|||
use rocket::fairing::{Fairing, Info, Kind};
|
||||
use rocket::http::Header;
|
||||
use rocket::{Request, Response};
|
||||
use rocket_contrib::databases::diesel;
|
||||
|
||||
pub struct CORS;
|
||||
|
||||
|
@ -36,9 +39,14 @@ impl Fairing for CORS {
|
|||
}
|
||||
}
|
||||
|
||||
// This defines a connection to the database
|
||||
#[database("postgres_fej")]
|
||||
struct FejDbConn(diesel::PgConnection);
|
||||
|
||||
fn rocket() -> rocket::Rocket {
|
||||
rocket::ignite()
|
||||
.attach(CORS)
|
||||
.attach(FejDbConn::fairing())
|
||||
.mount("/ivago", routes::ivago())
|
||||
.register(catchers![catchers::not_found])
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue