rise-deploy 0.16.4

A simple and powerful CLI for deploying containerized applications
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
pub mod routes;

use std::path::{Component, Path, PathBuf};

/// Load a static file from the configured static_dir, with path traversal protection.
pub async fn load_static_file(static_dir: &str, rel_path: &str) -> Option<Vec<u8>> {
    let mut safe_path = PathBuf::new();
    for part in Path::new(rel_path).components() {
        match part {
            Component::Normal(seg) => safe_path.push(seg),
            _ => return None,
        }
    }
    let full_path = PathBuf::from(static_dir).join(safe_path);
    tokio::fs::read(&full_path).await.ok()
}