35 lines
779 B
Rust
Raw Normal View History

2023-05-24 15:36:38 +02:00
use rocket::{get, routes, Route, State};
use sqlx::SqlitePool;
2023-10-28 14:48:08 +02:00
use crate::{
model::{log::Log, user::AdminUser},
tera::Config,
};
2023-04-04 10:44:14 +02:00
pub mod boat;
2023-04-04 12:19:56 +02:00
pub mod planned_event;
2023-04-04 10:44:14 +02:00
pub mod user;
2023-05-24 15:36:38 +02:00
#[get("/rss?<key>")]
2023-10-28 14:48:08 +02:00
async fn rss(db: &State<SqlitePool>, key: &str, config: &State<Config>) -> String {
if key.eq(&config.rss_key) {
Log::generate_feed(db).await
} else {
"Not allowed".into()
2023-05-24 15:36:38 +02:00
}
}
2023-10-28 14:48:08 +02:00
#[get("/rss", rank = 2)]
async fn show_rss(db: &State<SqlitePool>, _admin: AdminUser) -> String {
Log::show(db).await
}
2023-04-04 10:44:14 +02:00
pub fn routes() -> Vec<Route> {
let mut ret = Vec::new();
ret.append(&mut user::routes());
ret.append(&mut boat::routes());
2023-04-04 12:19:56 +02:00
ret.append(&mut planned_event::routes());
2023-10-28 14:48:08 +02:00
ret.append(&mut routes![rss, show_rss]);
2023-04-04 10:44:14 +02:00
ret
}