Skip to content

Commit 14dfc9f

Browse files
committed
static: Adjust to new conduit-mime-types API
1 parent 4ed12f3 commit 14dfc9f

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

conduit-static/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,12 @@ use time::OffsetDateTime;
77

88
pub struct Static {
99
path: PathBuf,
10-
types: mime::Types,
1110
}
1211

1312
impl Static {
1413
pub fn new<P: AsRef<Path>>(path: P) -> Static {
1514
Static {
1615
path: path.as_ref().to_path_buf(),
17-
types: mime::Types::new().expect("Couldn't load mime-types"),
1816
}
1917
}
2018
}
@@ -27,7 +25,7 @@ impl Handler for Static {
2725
}
2826

2927
let path = self.path.join(request_path);
30-
let mime = self.types.mime_for_path(&path);
28+
let mime = mime::mime_for_path(&path).unwrap_or("application/octet-stream");
3129
let file = match File::open(&path) {
3230
Ok(f) => f,
3331
Err(..) => return Ok(not_found()),
@@ -80,7 +78,7 @@ mod tests {
8078
let res = handler.call(&mut req).expect("No response");
8179
assert_eq!(
8280
res.headers().get(header::CONTENT_TYPE).unwrap(),
83-
"text/plain"
81+
"application/toml"
8482
);
8583
assert_eq!(res.headers().get(header::CONTENT_LENGTH).unwrap(), "9");
8684
assert_eq!(*res.into_cow(), b"[package]"[..]);

0 commit comments

Comments
 (0)