This commit is contained in:
Magnus Hoff 2017-10-02 17:11:18 +02:00
parent 1d485798eb
commit 02dd55df39

View file

@ -11,36 +11,32 @@ use state::State;
use web::{Lookup, Resource}; use web::{Lookup, Resource};
type BoxResource = Box<Resource + Sync + Send>; type BoxResource = Box<Resource + Sync + Send>;
type ResourceFn = Box<Fn(State) -> BoxResource + Sync + Send>;
lazy_static! { lazy_static! {
static ref LOOKUP_MAP: HashMap<String, Box<Fn(State) -> BoxResource + Sync + Send>> = { static ref LOOKUP_MAP: HashMap<String, ResourceFn> = {
let mut lookup_map = HashMap::new(); let mut lookup_map = HashMap::new();
lookup_map.insert( lookup_map.insert(
"/_new".to_string(), "/_new".to_string(),
Box::new(|state| Box::new(|state|
Box::new( Box::new(NewArticleResource::new(state, None)) as BoxResource
NewArticleResource::new(state, None) ) as ResourceFn
) as BoxResource
) as Box<Fn(State) -> BoxResource + Sync + Send>
); );
lookup_map.insert( lookup_map.insert(
format!("/_assets/style-{}.css", StyleCss::checksum()), format!("/_assets/style-{}.css", StyleCss::checksum()),
Box::new(|_| Box::new(StyleCss) as BoxResource) Box::new(|_| Box::new(StyleCss) as BoxResource) as ResourceFn
as Box<Fn(State) -> BoxResource + Sync + Send>
); );
lookup_map.insert( lookup_map.insert(
format!("/_assets/script-{}.js", ScriptJs::checksum()), format!("/_assets/script-{}.js", ScriptJs::checksum()),
Box::new(|_| Box::new(ScriptJs) as BoxResource) Box::new(|_| Box::new(ScriptJs) as BoxResource) as ResourceFn
as Box<Fn(State) -> BoxResource + Sync + Send>
); );
lookup_map.insert( lookup_map.insert(
format!("/_assets/amatic-sc-v9-latin-regular.woff"), format!("/_assets/amatic-sc-v9-latin-regular.woff"),
Box::new(|_| Box::new(AmaticFont) as BoxResource) Box::new(|_| Box::new(AmaticFont) as BoxResource) as ResourceFn
as Box<Fn(State) -> BoxResource + Sync + Send>
); );
lookup_map lookup_map