Serve favicon
This commit is contained in:
parent
8e570c0594
commit
5ef0a218c2
15
src/main.rs
15
src/main.rs
@ -1,4 +1,6 @@
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
|
extern crate actix_web;
|
||||||
|
#[macro_use]
|
||||||
extern crate lazy_static;
|
extern crate lazy_static;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
@ -12,6 +14,7 @@ use crate::{
|
|||||||
data::FilePath,
|
data::FilePath,
|
||||||
error::Result,
|
error::Result,
|
||||||
service::{Bitbucket, GitLab, Github, Service},
|
service::{Bitbucket, GitLab, Github, Service},
|
||||||
|
statics::FAVICON,
|
||||||
};
|
};
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
http::header::{self, CacheControl, CacheDirective, Expires},
|
http::header::{self, CacheControl, CacheDirective, Expires},
|
||||||
@ -79,6 +82,17 @@ fn handle_request<T: Service>(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[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<()> {
|
fn main() -> Result<()> {
|
||||||
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=trace");
|
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=trace");
|
||||||
pretty_env_logger::init();
|
pretty_env_logger::init();
|
||||||
@ -88,6 +102,7 @@ fn main() -> Result<()> {
|
|||||||
App::new()
|
App::new()
|
||||||
.data(Client::new())
|
.data(Client::new())
|
||||||
.wrap(middleware::Logger::default())
|
.wrap(middleware::Logger::default())
|
||||||
|
.service(favicon32)
|
||||||
.route(
|
.route(
|
||||||
"/github/{user}/{repo}/{commit}/{file:.*}",
|
"/github/{user}/{repo}/{commit}/{file:.*}",
|
||||||
web::get().to_async(handle_request::<Github>),
|
web::get().to_async(handle_request::<Github>),
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
const VERSION: &str = env!("CARGO_PKG_VERSION");
|
||||||
|
pub(crate) const FAVICON: &[u8] = include_bytes!("../static/favicon32.png");
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
pub(crate) static ref USER_AGENT: String = format!("gitache/{}", VERSION);
|
pub(crate) static ref USER_AGENT: String = format!("gitache/{}", VERSION);
|
||||||
}
|
}
|
||||||
|
BIN
static/favicon32.png
Normal file
BIN
static/favicon32.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 983 B |
Loading…
Reference in New Issue
Block a user