Simplify naming

This commit is contained in:
asonix 2020-01-17 17:13:15 -06:00
parent 1d37ebb812
commit 1202b7ff43

View file

@ -35,7 +35,7 @@ pub enum ParseDigestError {
#[error("Could not parse request body")]
pub struct ParseBodyError;
pub fn verify_digest_bytes(
pub fn verify_bytes(
verifier: impl DigestVerify + Clone + Send,
) -> impl Filter<Extract = (Bytes,), Error = Rejection> + Clone {
parse_digest_header()
@ -52,26 +52,26 @@ pub fn verify_digest_bytes(
})
}
pub fn verify_digest_json<T>(
pub fn verify_json<T>(
verifier: impl DigestVerify + Clone + Send
) -> impl Filter<Extract = (T,), Error = Rejection> + Clone
where
T: serde::de::DeserializeOwned,
{
verify_digest_bytes(verifier).and_then(|bytes: Bytes| {
verify_bytes(verifier).and_then(|bytes: Bytes| {
async move {
serde_json::from_slice(&bytes).map_err(|_| warp::reject::custom(ParseBodyError))
}
})
}
pub fn verify_digest_form<T>(
pub fn verify_form<T>(
verifier: impl DigestVerify + Clone + Send,
) -> impl Filter<Extract = (T,), Error = Rejection> + Clone
where
T: serde::de::DeserializeOwned,
{
verify_digest_bytes(verifier).and_then(|bytes: Bytes| {
verify_bytes(verifier).and_then(|bytes: Bytes| {
async move {
serde_urlencoded::from_bytes(&bytes).map_err(|_| warp::reject::custom(ParseBodyError))
}