Machine readable branding.
Include project name and version in Server header and generator meta tag
This commit is contained in:
parent
2626223f10
commit
78bd53e640
2 changed files with 13 additions and 7 deletions
19
src/site.rs
19
src/site.rs
|
@ -4,7 +4,7 @@
|
|||
use std::fmt;
|
||||
|
||||
use futures::{self, Future};
|
||||
use hyper::header::{Accept, ContentType};
|
||||
use hyper::header::{Accept, ContentType, Server};
|
||||
use hyper::mime;
|
||||
use hyper::server::*;
|
||||
use hyper;
|
||||
|
@ -28,13 +28,11 @@ pub struct Layout<'a, T: 'a + fmt::Display> {
|
|||
}
|
||||
|
||||
impl<'a, T: 'a + fmt::Display> Layout<'a, T> {
|
||||
pub fn style_css_checksum(&self) -> &str {
|
||||
StyleCss::checksum()
|
||||
}
|
||||
pub fn style_css_checksum(&self) -> &str { StyleCss::checksum() }
|
||||
pub fn search_js_checksum(&self) -> &str { SearchJs::checksum() }
|
||||
|
||||
pub fn search_js_checksum(&self) -> &str {
|
||||
SearchJs::checksum()
|
||||
}
|
||||
pub fn pkg_name(&self) -> &str { env!("CARGO_PKG_NAME") }
|
||||
pub fn pkg_version(&self) -> &str { env!("CARGO_PKG_VERSION") }
|
||||
}
|
||||
|
||||
#[derive(BartDisplay)]
|
||||
|
@ -128,6 +126,13 @@ impl Service for Site {
|
|||
None => Box::new(futures::finished(Self::not_found(base.as_ref().map(|x| &**x))))
|
||||
})
|
||||
.or_else(move |err| Ok(Self::internal_server_error(base2.as_ref().map(|x| &**x), err)))
|
||||
.map(|response| response
|
||||
.with_header(Server::new(concat!(
|
||||
env!("CARGO_PKG_NAME"),
|
||||
"/",
|
||||
env!("CARGO_PKG_VERSION")
|
||||
)))
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
{{#base}}<base href="{{.}}">{{/base}}
|
||||
<link rel=preload href="_assets/amatic-sc-v9-latin-regular.woff" as=font crossorigin>
|
||||
<link href="_assets/style-{{style_css_checksum()}}.css" rel="stylesheet">
|
||||
<meta name="generator" content="{{pkg_name()}} {{pkg_version()}}" />
|
||||
</head>
|
||||
<body>
|
||||
{{>search_input.html}}
|
||||
|
|
Loading…
Reference in a new issue