aboutsummaryrefslogtreecommitdiff
path: root/src/controller/utils.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/controller/utils.rs')
-rw-r--r--src/controller/utils.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/controller/utils.rs b/src/controller/utils.rs
index 544cdf8..bd3007e 100644
--- a/src/controller/utils.rs
+++ b/src/controller/utils.rs
@@ -120,11 +120,17 @@ pub fn not_found() -> Response<Body> {
response
}
-pub async fn file(filename: &str) -> Response<Body> {
+pub async fn file(filename: &str, content_type: &str) -> Response<Body> {
if let Ok(file) = File::open(filename).await {
let stream = FramedRead::new(file, BytesCodec::new());
let body = Body::wrap_stream(stream);
- with_header(Response::new(body), CACHE_CONTROL, "max-age=3153600000")
+ with_headers(
+ Response::new(body),
+ vec![
+ (CACHE_CONTROL, "max-age=3153600000"),
+ (CONTENT_TYPE, content_type),
+ ],
+ )
} else {
not_found()
}