[][src]Function hyperbole::prelude::reply::filesystem_path

pub fn filesystem_path(
    base_path: &str
) -> impl Fn(HCons<Method, HCons<Field<String, { "path" }>, HCons<HeaderMap, HNil>>>) -> FsFuture

Handle a request by serving a file from the filesystem. Unlike filesystem, the file path to be served will be the named field path: String appended to base_path.

Examples

use hyperbole::{r, reply, uri, Ctx, R};

let _ctx = Ctx::default()
    // use a uri! parser to extract `path: String` from the uri
    .get(uri!["css" / *path: String], reply::filesystem_path("/srv"))
    // or populate `path: String` in a middleware
    .map(|cx: R![]| r![path = "an-image-file.jpg".to_owned()])
    .get(uri!["image"], reply::filesystem_path("/srv"));