From 5ef0a218c28d9501a22c3fc835d392bf26d530a7 Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Sat, 27 Jul 2019 16:15:11 +0200 Subject: [PATCH] Serve favicon --- src/main.rs | 15 +++++++++++++++ src/statics.rs | 1 + static/favicon32.png | Bin 0 -> 983 bytes 3 files changed, 16 insertions(+) create mode 100644 static/favicon32.png 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 0000000000000000000000000000000000000000..09caf7cfdb3ea8f9032556b00ce0295cc7e46e9e GIT binary patch literal 983 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyEa{HEjtmSN`?>!lvVtU&J%W50 z7^>757#dm_7=8hT8eT9klo~KFyh>nTu$sZZAYL$MSD+081EXw!Plzi}!G{3jQG^)+ z|NsB@F}tS;44~MOAirP+2Ih)S?{XNK@;|>%VJ-afA=T&w3unpKB@)F2>%^Z+YMS)_ zn7p~|lxWiTzjFo4xl2FpIP?4DDmI~xKiU7Hq;9;45jeM&KYUxyGt<+GD<2puEt{3W z6Y}!g(F2KZGm9=r+yq+0nB?v56322aaW{~|UgGKN%Kn&@SA@-cvfEr1ptPT-i(`nz z>DtSg;Y|)A4G(wfHR!Z0&Fq+&d&?^=)vG%-_4mH(fB)AnPPCFuOUT$~_`di7p9}}5 zxP#W*lUiB~6ZIH$mn%!9O=8ftZ!5XUx{{&cBj*tp#sHnj$xmGz=g(j7(>PfrWBs&? zYa5MoPrF=b{&}aWaG9aCxNyB};kk9I)B7Epb}frK zTI%>gHZZ?Jx^$|z%GAeJ+oa=_Nl6AYyozmAEiEJ-t`0l)s`;p?0h`k=qkFM}On7pOfslG~Y@1A2;>i6#1=Xk15 z+UO_ zQmvAUQh^kMk%6J5u7Rnpp>c?jft7)om9eF^0gz#^d7|V!6b-rgDVb@NPz@%!h9)5f d=2pgLR)&TU4RaouECgy`@O1TaS?83{1OU~-nk@hT literal 0 HcmV?d00001