teo 0.2.6-alpha.5

Next-generation web framework for Rust, Node.js and Python.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use std::path::PathBuf;
use teo_runtime::path;
use teo_runtime::response::Response;

pub fn serve_static_files(base: impl AsRef<str>, path: impl AsRef<str>) -> path::Result<Response> {
    let base_str = base.as_ref();
    let path_str = path.as_ref();
    let combined_path = PathBuf::from(base_str).join(path_str);
    if combined_path.is_file() {
        Ok(Response::file(combined_path))
    } else {
        Err(path::Error::not_found_message_only())
    }
}