diff options
author | Matthias Beyer <mail@beyermatthias.de> | 2020-05-22 11:37:45 +0200 |
---|---|---|
committer | Matthias Beyer <mail@beyermatthias.de> | 2020-05-22 11:38:17 +0200 |
commit | f683ec4ad3e9716623e053a5d8f9fbbf257801ec (patch) | |
tree | 29bf0e06f60c75da2361c94fa87309df27d5c8d4 | |
parent | f904eb2e98a30865207f954184b15b195f41aefc (diff) |
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
-rw-r--r-- | src/main.rs | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 4bfea0c..1863f2d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -166,10 +166,7 @@ async fn on_get(req: Request<Body>) -> Result<Response<Body>, Box<dyn Error>> { return Ok(respond_404()?); } - let extension = match &Path::new(path).extension() { - Some(ext) => Some(ext.to_string_lossy()), - None => None, - }; + let extension = Path::new(path).extension().as_ref().map(|e| e.to_string_lossy()); // If we have an extension, we need to serve with the appropriate Content-Type let mime = extension.as_ref().and_then(|ext| mime_guess::from_ext(ext).first_raw()); |