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:
trotFunky 2024-07-27 21:22:34 +01:00
parent 120472354c
commit 222acbb4f8
6 changed files with 28 additions and 10 deletions

View file

@ -36,13 +36,11 @@ async fn index(mut db: Connection<Db>) -> Redirect {
fn rocket() -> _ {
rocket::build()
.mount("/", FileServer::from(relative!("static_files")))
.mount("/", routes![index,
vote::fetch_vote_data, vote::vote,
truth::create_truth, truth::edit_truth,
week::week, week::update_week, week::set_last_week, week::create_week,
auth::login, auth::logout])
.attach(auth::stage())
.attach(week::stage())
.attach(truth::stage())
.attach(vote::stage())
.mount("/", routes![index])
.attach(database::stage())
.attach(Template::fairing())
}
// TODO: Random Row ID