mirror of
https://github.com/sigoden/dufs
synced 2024-10-06 07:49:43 +00:00
feat: add favicon (#27)
Return favicon only if requested, avoid 404 errors close #16
This commit is contained in:
parent
5ce7bde05c
commit
261c8b6ee5
BIN
assets/favicon.ico
Executable file
BIN
assets/favicon.ico
Executable file
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
|
@ -44,6 +44,7 @@ type Response = hyper::Response<Body>;
|
|||
const INDEX_HTML: &str = include_str!("../assets/index.html");
|
||||
const INDEX_CSS: &str = include_str!("../assets/index.css");
|
||||
const INDEX_JS: &str = include_str!("../assets/index.js");
|
||||
const FAVICON_ICO: &[u8] = include_bytes!("../assets/favicon.ico");
|
||||
const INDEX_NAME: &str = "index.html";
|
||||
const BUF_SIZE: usize = 1024 * 16;
|
||||
|
||||
|
@ -174,6 +175,12 @@ impl InnerService {
|
|||
status!(res, StatusCode::NOT_FOUND);
|
||||
return Ok(res);
|
||||
}
|
||||
if is_miss && path.ends_with("favicon.ico") {
|
||||
*res.body_mut() = Body::from(FAVICON_ICO);
|
||||
res.headers_mut()
|
||||
.insert("content-type", "image/x-icon".parse().unwrap());
|
||||
return Ok(res);
|
||||
}
|
||||
|
||||
let headers = req.headers();
|
||||
|
||||
|
|
Loading…
Reference in a new issue