Skip to content

Commit

Permalink
Merge pull request #14 from stappersg/favicon
Browse files Browse the repository at this point in the history
Added favicon.ico
  • Loading branch information
w4 authored Aug 26, 2023
2 parents dab5dc3 + de15cca commit b355ac6
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ async fn main() {
.into_boxed_bytes(),
);

let static_favicon = |content: &'static [u8]| {
move || async move {
let mut resp = Response::new(Body::from(content));
resp.headers_mut().insert(
http::header::CONTENT_TYPE,
HeaderValue::from_static("image/x-icon"),
);
resp
}
};

let static_css = |content: &'static [u8]| {
move || async move {
let mut resp = Response::new(Body::from(content));
Expand All @@ -114,6 +125,10 @@ async fn main() {
)
.route("/highlight.css", get(static_css(css)))
.route("/highlight-dark.css", get(static_css(dark_css)))
.route(
"/favicon.ico",
get(static_favicon(include_bytes!("../statics/favicon.ico"))),
)
.fallback(methods::repo::service)
.layer(layer_fn(LoggingMiddleware))
.layer(Extension(Arc::new(Git::new(syntax_set))))
Expand Down
5 changes: 5 additions & 0 deletions statics/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Current favicon.ico was retrieved
by `wget https://www.git-scm.com/favicon.ico`

When you have a better favicon.ico for this project
contact us.
Binary file added statics/favicon.ico
Binary file not shown.

0 comments on commit b355ac6

Please sign in to comment.