2024-01-01 15:50:06 +01:00

37 lines
830 B
Rust

use rocket::{get, routes, Route, State};
use sqlx::SqlitePool;
use crate::{
model::{log::Log, user::AdminUser},
tera::Config,
};
pub mod boat;
pub mod mail;
pub mod planned_event;
pub mod user;
#[get("/rss?<key>")]
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()
}
}
#[get("/rss", rank = 2)]
async fn show_rss(db: &State<SqlitePool>, _admin: AdminUser) -> String {
Log::show(db).await
}
pub fn routes() -> Vec<Route> {
let mut ret = Vec::new();
ret.append(&mut user::routes());
ret.append(&mut boat::routes());
ret.append(&mut mail::routes());
ret.append(&mut planned_event::routes());
ret.append(&mut routes![rss, show_rss]);
ret
}