Skip to content

Commit b451450

Browse files
authored
Merge pull request #52 from conduit-rust/renovate/conduit-mime-types-0.x
Update Rust crate conduit-mime-types to 0.8
2 parents d55c881 + 14dfc9f commit b451450

File tree

3 files changed

+122
-15
lines changed

3 files changed

+122
-15
lines changed

Cargo.lock

Lines changed: 119 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

conduit-static/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ edition = "2018"
1010

1111
[dependencies]
1212
conduit = { version = "0.9.0-alpha.5", path = "../conduit" }
13-
conduit-mime-types = "0.7"
13+
conduit-mime-types = "0.8"
1414
time = { version = "0.2", default-features = false, features = ["std"] }
1515
filetime = "0.2"
1616

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)