Configure permissions properly on Rocket.toml. Make static path behave better

This commit is contained in:
jude
2023-06-14 13:29:48 +01:00
parent c824a36832
commit cdfe44d958
6 changed files with 36 additions and 15 deletions

View File

@ -6,7 +6,7 @@ mod consts;
mod macros;
mod routes;
use std::{collections::HashMap, env};
use std::{collections::HashMap, env, path::Path};
use oauth2::{basic::BasicClient, AuthUrl, ClientId, ClientSecret, RedirectUrl, TokenUrl};
use rocket::{
@ -88,6 +88,9 @@ pub async fn initialize(
let reqwest_client = reqwest::Client::new();
let static_path =
if Path::new("web/static").exists() { "web/static" } else { "/lib/reminder-rs/static" };
rocket::build()
.attach(Template::fairing())
.register(
@ -105,7 +108,7 @@ pub async fn initialize(
.manage(reqwest_client)
.manage(serenity_context)
.manage(db_pool)
.mount("/static", FileServer::from("/lib/reminder-rs/static"))
.mount("/static", FileServer::from(static_path))
.mount(
"/",
routes![