Slightly less mindless copying
This commit is contained in:
parent
b21a7ccda4
commit
2a5f98d43e
1 changed files with 7 additions and 7 deletions
|
@ -11,7 +11,7 @@ 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>;
|
type ResourceFn = Box<Fn(&State) -> BoxResource + Sync + Send>;
|
||||||
|
|
||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref LOOKUP_MAP: HashMap<String, ResourceFn> = {
|
static ref LOOKUP_MAP: HashMap<String, ResourceFn> = {
|
||||||
|
@ -19,24 +19,24 @@ lazy_static! {
|
||||||
|
|
||||||
lookup_map.insert(
|
lookup_map.insert(
|
||||||
"/_new".to_string(),
|
"/_new".to_string(),
|
||||||
Box::new(|state|
|
Box::new(|state: &State|
|
||||||
Box::new(NewArticleResource::new(state, None)) as BoxResource
|
Box::new(NewArticleResource::new(state.clone(), None)) as BoxResource
|
||||||
) as ResourceFn
|
) as ResourceFn
|
||||||
);
|
);
|
||||||
|
|
||||||
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) as ResourceFn
|
Box::new(|_: &State| Box::new(StyleCss) as BoxResource) as ResourceFn
|
||||||
);
|
);
|
||||||
|
|
||||||
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) as ResourceFn
|
Box::new(|_: &State| Box::new(ScriptJs) as BoxResource) as ResourceFn
|
||||||
);
|
);
|
||||||
|
|
||||||
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) as ResourceFn
|
Box::new(|_: &State| Box::new(AmaticFont) as BoxResource) as ResourceFn
|
||||||
);
|
);
|
||||||
|
|
||||||
lookup_map
|
lookup_map
|
||||||
|
@ -66,7 +66,7 @@ impl Lookup for WikiLookup {
|
||||||
// Reserved namespace
|
// Reserved namespace
|
||||||
|
|
||||||
return Box::new(finished(
|
return Box::new(finished(
|
||||||
LOOKUP_MAP.get(path).map(|x| x(self.state.clone()))
|
LOOKUP_MAP.get(path).map(|x| x(&self.state))
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue