This repository has been archived on 2023-03-28. You can view files and clone it, but cannot push or open issues or pull requests.
2020-10-15 00:16:06 +00:00
|
|
|
use crate::config;
|
|
|
|
use crate::database;
|
|
|
|
use crate::routes;
|
|
|
|
|
2020-10-15 18:59:58 +00:00
|
|
|
use rocket_contrib::serve::StaticFiles;
|
2020-10-15 00:16:06 +00:00
|
|
|
use rocket_contrib::templates::Template;
|
|
|
|
|
2020-10-15 18:59:58 +00:00
|
|
|
pub fn rocket(config: config::Config) -> Result<rocket::Rocket, ()> {
|
|
|
|
let rocket_config = config.to_rocket_config()?;
|
|
|
|
|
|
|
|
let public_path = config.public_path()?;
|
|
|
|
|
|
|
|
let result = rocket::custom(rocket_config)
|
2020-10-15 00:16:06 +00:00
|
|
|
.manage(database::create_db_pool(config))
|
|
|
|
.attach(Template::fairing())
|
|
|
|
.mount("/", routes::routes())
|
2020-10-15 18:59:58 +00:00
|
|
|
.mount("/public", StaticFiles::from(public_path));
|
|
|
|
|
|
|
|
Ok(result)
|
2020-10-15 00:16:06 +00:00
|
|
|
}
|