Rocket: Use fairings for routes of sub-files
Instead of adding all routes manually in the Launch function for Rocket, implement fairings for all the different files that adds the routing to the rocket in a self-contained manner.
This commit is contained in:
parent
120472354c
commit
222acbb4f8
6 changed files with 28 additions and 10 deletions
|
@ -5,6 +5,7 @@ use rocket::response::Redirect;
|
|||
use rocket_db_pools::{sqlx, Connection};
|
||||
|
||||
use pulldown_cmark::{Parser, Options};
|
||||
use rocket::fairing::AdHoc;
|
||||
use sqlx::Row;
|
||||
use crate::{auth, database, week};
|
||||
|
||||
|
@ -110,3 +111,9 @@ pub async fn create_truth(week: u8, form: Form<TruthUpdateForm>,
|
|||
|
||||
Redirect::to(uri!(week::week(week)))
|
||||
}
|
||||
|
||||
pub fn stage() -> AdHoc {
|
||||
AdHoc::on_ignite("Truth stage", |rocket| async {
|
||||
rocket.mount("/", routes![create_truth, edit_truth])
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue