mirror of
https://git.asonix.dog/asonix/http-signature-normalization.git
synced 2024-11-21 17:00:59 +00:00
Simplify passing verifier
This commit is contained in:
parent
51bd0ad1ef
commit
1d37ebb812
1 changed files with 10 additions and 15 deletions
|
@ -35,16 +35,13 @@ pub enum ParseDigestError {
|
|||
#[error("Could not parse request body")]
|
||||
pub struct ParseBodyError;
|
||||
|
||||
pub fn verify_digest_bytes<D>(
|
||||
verifier: impl Filter<Extract = (D,), Error = Rejection> + Clone,
|
||||
) -> impl Filter<Extract = (Bytes,), Error = Rejection> + Clone
|
||||
where
|
||||
D: DigestVerify + Send,
|
||||
{
|
||||
verifier
|
||||
.and(parse_digest_header())
|
||||
pub fn verify_digest_bytes(
|
||||
verifier: impl DigestVerify + Clone + Send,
|
||||
) -> impl Filter<Extract = (Bytes,), Error = Rejection> + Clone {
|
||||
parse_digest_header()
|
||||
.and(body::bytes())
|
||||
.and_then(|mut verifier: D, parts: Vec<DigestPart>, bytes: Bytes| {
|
||||
.and_then(move |parts: Vec<DigestPart>, bytes: Bytes| {
|
||||
let mut verifier = verifier.clone();
|
||||
async move {
|
||||
if verifier.verify(&parts, &bytes) {
|
||||
Ok(bytes)
|
||||
|
@ -55,11 +52,10 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
pub fn verify_digest_json<D, T>(
|
||||
verifier: impl Filter<Extract = (D,), Error = Rejection> + Clone,
|
||||
pub fn verify_digest_json<T>(
|
||||
verifier: impl DigestVerify + Clone + Send
|
||||
) -> impl Filter<Extract = (T,), Error = Rejection> + Clone
|
||||
where
|
||||
D: DigestVerify + Send,
|
||||
T: serde::de::DeserializeOwned,
|
||||
{
|
||||
verify_digest_bytes(verifier).and_then(|bytes: Bytes| {
|
||||
|
@ -69,11 +65,10 @@ where
|
|||
})
|
||||
}
|
||||
|
||||
pub fn verify_digest_form<D, T>(
|
||||
verifier: impl Filter<Extract = (D,), Error = Rejection> + Clone,
|
||||
pub fn verify_digest_form<T>(
|
||||
verifier: impl DigestVerify + Clone + Send,
|
||||
) -> impl Filter<Extract = (T,), Error = Rejection> + Clone
|
||||
where
|
||||
D: DigestVerify + Send,
|
||||
T: serde::de::DeserializeOwned,
|
||||
{
|
||||
verify_digest_bytes(verifier).and_then(|bytes: Bytes| {
|
||||
|
|
Loading…
Reference in a new issue