You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
748 B
35 lines
748 B
#[macro_use] |
|
extern crate rocket; |
|
|
|
#[macro_use] |
|
extern crate diesel; |
|
|
|
mod random_hasher; |
|
mod models; |
|
mod schema; |
|
mod api; |
|
|
|
use random_hasher::RandomHasher; |
|
|
|
#[launch] |
|
fn rocket() -> _ { |
|
load_env(); |
|
rocket::build() |
|
.mount("/_api", routes![ |
|
api::post::get_list, |
|
api::post::get_one, |
|
api::post::publish_post |
|
]) |
|
.register("/_api", catchers![ |
|
api::catch_401_error |
|
]) |
|
.manage(RandomHasher::get_random_one()) |
|
} |
|
|
|
fn load_env() { |
|
match dotenv::dotenv() { |
|
Ok(path) => eprintln!("Configuration read from {}", path.display()), |
|
Err(ref e) if e.not_found() => eprintln!("Warning: no .env was found"), |
|
e => e.map(|_| ()).unwrap(), |
|
} |
|
}
|
|
|