Introduce a rocket factory in preparation for tests.
This commit is contained in:
parent
4adf524f99
commit
0c8c4fe623
|
@ -567,6 +567,12 @@ pub fn serve(opt: &Opt, db: Polymorphic) -> Result<()> {
|
||||||
.extra("domain", opt.domain.clone())
|
.extra("domain", opt.domain.clone())
|
||||||
.extra("from", opt.from.clone())
|
.extra("from", opt.from.clone())
|
||||||
.finalize()?;
|
.finalize()?;
|
||||||
|
|
||||||
|
rocket_factory(rocket::custom(config), db).launch();
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn rocket_factory(rocket: rocket::Rocket, db: Polymorphic) -> rocket::Rocket {
|
||||||
let routes = routes![
|
let routes = routes![
|
||||||
// infra
|
// infra
|
||||||
root,
|
root,
|
||||||
|
@ -588,7 +594,7 @@ pub fn serve(opt: &Opt, db: Polymorphic) -> Result<()> {
|
||||||
about,
|
about,
|
||||||
];
|
];
|
||||||
|
|
||||||
rocket::custom(config)
|
rocket
|
||||||
.attach(Template::fairing())
|
.attach(Template::fairing())
|
||||||
.attach(AdHoc::on_attach("static_dir", |rocket| {
|
.attach(AdHoc::on_attach("static_dir", |rocket| {
|
||||||
let static_dir =
|
let static_dir =
|
||||||
|
@ -636,6 +642,4 @@ pub fn serve(opt: &Opt, db: Polymorphic) -> Result<()> {
|
||||||
}))
|
}))
|
||||||
.mount("/", routes)
|
.mount("/", routes)
|
||||||
.manage(db)
|
.manage(db)
|
||||||
.launch();
|
|
||||||
Ok(())
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue