After creating a simple test case I managed to get it going with the following function.
pub fn haystack_auth_header(store: Store) -> impl Filter + Clone {
warp::header("Authorization").and_then (
move |auth_header: String|
{
let tmp = store.clone();
async move {
let tmp = tmp.clone();
if tmp.read().get_authtoken().is_none() {
return Err(reject::custom(HayStackAuthToken));
}
Ok(tmp.clone())
}
}
)
}
So in the end just needed clone in the correct place.