feat: smarter paths
This commit is contained in:
parent
6b96aa49b9
commit
53b1f4f244
2 changed files with 13 additions and 2 deletions
13
src/lib.rs
13
src/lib.rs
|
@ -10,4 +10,15 @@ pub use views::*;
|
|||
|
||||
use std::{path::PathBuf, sync::LazyLock};
|
||||
|
||||
pub static CACHE_DIR: LazyLock<PathBuf> = LazyLock::new(|| PathBuf::from("/var/lib/nyazoom/cache"));
|
||||
pub static CACHE_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
|
||||
std::env::var("CACHE_DIR")
|
||||
.ok()
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| PathBuf::from("/var/lib/nyazoom/cache"))
|
||||
});
|
||||
pub static DIST_DIR: LazyLock<PathBuf> = LazyLock::new(|| {
|
||||
std::env::var("DIST_DIR")
|
||||
.ok()
|
||||
.map(PathBuf::from)
|
||||
.unwrap_or_else(|| PathBuf::from("./dist"))
|
||||
});
|
||||
|
|
|
@ -34,7 +34,7 @@ async fn main() -> io::Result<()> {
|
|||
.nest("/records", get_records_router())
|
||||
.nest("/link", get_link_router())
|
||||
.with_state(state)
|
||||
.fallback_service(ServeDir::new("dist"))
|
||||
.fallback_service(ServeDir::new(&*DIST_DIR))
|
||||
.layer(TraceLayer::new_for_http())
|
||||
.layer(middleware::from_fn(log_source));
|
||||
|
||||
|
|
Loading…
Reference in a new issue