diff --git a/assets/favicon.ico b/assets/favicon.ico new file mode 100755 index 0000000..57d3531 Binary files /dev/null and b/assets/favicon.ico differ diff --git a/src/server.rs b/src/server.rs index cda0804..bf89df0 100644 --- a/src/server.rs +++ b/src/server.rs @@ -44,6 +44,7 @@ type Response = hyper::Response; 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();