kutil_http/file/
response.rs

1use {
2    http::{header::*, *},
3    std::path::*,
4    tower::*,
5    tower_http::services::fs::*,
6};
7
8/// Create a [Response] from a file.
9pub async fn response_from_file<PathT>(path: PathT, negotiable: bool) -> Response<ServeFileSystemResponseBody>
10where
11    PathT: AsRef<Path>,
12{
13    let mut response = ServeFile::new(path).oneshot(Request::new(())).await.expect("infallible");
14
15    if !negotiable {
16        response.headers_mut().remove(LAST_MODIFIED);
17    }
18
19    response
20}