1
0
Fork 0
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.
fedihub-website/src/web.rs

22 lines
646 B
Rust
Raw Normal View History

2020-10-15 00:16:06 +00:00
use crate::config;
use crate::database;
use crate::routes;
2020-10-15 19:06:09 +00:00
use rocket_contrib::serve::{Options as ServeOptions, StaticFiles};
2020-10-15 00:16:06 +00:00
use rocket_contrib::templates::Template;
2020-10-16 05:33:52 +00:00
pub fn rocket(config: &config::Config) -> Result<rocket::Rocket, ()> {
2020-10-15 18:59:58 +00:00
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))
2020-10-16 21:33:24 +00:00
.attach(rocket_csrf::Fairing::new())
2020-10-15 00:16:06 +00:00
.attach(Template::fairing())
.mount("/", routes::routes())
2020-10-15 20:41:22 +00:00
.mount("/", StaticFiles::new(public_path, ServeOptions::None));
2020-10-15 18:59:58 +00:00
Ok(result)
2020-10-15 00:16:06 +00:00
}