Use version info struct

This commit is contained in:
Valentin Brandl 2019-04-30 14:19:40 +02:00
parent f6cbe92eba
commit bdf9d382d4
No known key found for this signature in database
GPG Key ID: 30D341DD34118D7D

View File

@ -36,25 +36,32 @@ use structopt::StructOpt;
include!(concat!(env!("OUT_DIR"), "/templates.rs")); include!(concat!(env!("OUT_DIR"), "/templates.rs"));
const COMMIT: &str = env!("VERGEN_SHA_SHORT"); pub struct VersionInfo<'a> {
const VERSION: &str = env!("CARGO_PKG_VERSION"); pub commit: &'a str,
pub version: &'a str,
}
const VERSION_INFO: VersionInfo = VersionInfo {
commit: env!("VERGEN_SHA_SHORT"),
version: env!("CARGO_PKG_VERSION"),
};
lazy_static! { lazy_static! {
static ref CLIENT: reqwest::Client = reqwest::Client::new(); static ref CLIENT: reqwest::Client = reqwest::Client::new();
static ref OPT: Opt = Opt::from_args(); static ref OPT: Opt = Opt::from_args();
static ref INDEX: Vec<u8> = { static ref INDEX: Vec<u8> = {
let mut buf = Vec::new(); let mut buf = Vec::new();
templates::index(&mut buf, COMMIT, VERSION, &OPT.domain).unwrap(); templates::index(&mut buf, VERSION_INFO, &OPT.domain).unwrap();
buf buf
}; };
static ref P404: Vec<u8> = { static ref P404: Vec<u8> = {
let mut buf = Vec::new(); let mut buf = Vec::new();
templates::p404(&mut buf, COMMIT, VERSION).unwrap(); templates::p404(&mut buf, VERSION_INFO).unwrap();
buf buf
}; };
static ref P500: Vec<u8> = { static ref P500: Vec<u8> = {
let mut buf = Vec::new(); let mut buf = Vec::new();
templates::p500(&mut buf, COMMIT, VERSION).unwrap(); templates::p500(&mut buf, VERSION_INFO).unwrap();
buf buf
}; };
} }
@ -228,8 +235,7 @@ fn overview<T: Service>(
let req_path = format!("{}/{}/{}", T::url_path(), data.0, data.1); let req_path = format!("{}/{}/{}", T::url_path(), data.0, data.1);
templates::overview( templates::overview(
&mut buf, &mut buf,
COMMIT, VERSION_INFO,
VERSION,
&OPT.domain, &OPT.domain,
&req_path, &req_path,
&url, &url,