diff --git a/src/main.rs b/src/main.rs index fdeaf20..4d921fa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,6 @@ #[macro_use] +extern crate actix_web; +#[macro_use] extern crate lazy_static; #[macro_use] extern crate serde_derive; @@ -12,6 +14,7 @@ use crate::{ data::FilePath, error::Result, service::{Bitbucket, GitLab, Github, Service}, + statics::FAVICON, }; use actix_web::{ http::header::{self, CacheControl, CacheDirective, Expires}, @@ -79,6 +82,17 @@ fn handle_request( } } +#[get("/favicon.ico")] +fn favicon32() -> HttpResponse { + HttpResponse::Ok() + .content_type("image/png") + .set(CacheControl(vec![ + CacheDirective::Public, + CacheDirective::MaxAge(2_592_000_000), + ])) + .body(FAVICON) +} + fn main() -> Result<()> { std::env::set_var("RUST_LOG", "actix_server=info,actix_web=trace"); pretty_env_logger::init(); @@ -88,6 +102,7 @@ fn main() -> Result<()> { App::new() .data(Client::new()) .wrap(middleware::Logger::default()) + .service(favicon32) .route( "/github/{user}/{repo}/{commit}/{file:.*}", web::get().to_async(handle_request::), diff --git a/src/statics.rs b/src/statics.rs index 9608314..cd3fcb5 100644 --- a/src/statics.rs +++ b/src/statics.rs @@ -1,4 +1,5 @@ const VERSION: &str = env!("CARGO_PKG_VERSION"); +pub(crate) const FAVICON: &[u8] = include_bytes!("../static/favicon32.png"); lazy_static! { pub(crate) static ref USER_AGENT: String = format!("gitache/{}", VERSION); } diff --git a/static/favicon32.png b/static/favicon32.png new file mode 100644 index 0000000..09caf7c Binary files /dev/null and b/static/favicon32.png differ