feat: implement IntoLayer for slices (IntoIter)

This commit is contained in:
cduvray 2023-08-14 08:04:53 +02:00
parent 36bc0fca7d
commit efa378b3bf
2 changed files with 3 additions and 2 deletions

View file

@ -209,8 +209,9 @@ where
}
#[async_trait]
impl<C> IntoLayer<C> for Vec<JwtAuthorizer<C>>
impl<C, T> IntoLayer<C> for T
where
T: IntoIterator<Item = JwtAuthorizer<C>> + Send + Sync,
C: Clone + DeserializeOwned + Send + Sync,
{
async fn into_layer(self) -> Result<AsyncAuthorizationLayer<C>, InitError> {

View file

@ -352,7 +352,7 @@ mod tests {
proteced_request_with_header(auths, header::COOKIE.as_str(), &format!("ccc={}", common::JWT_RSA1_OK)).await;
assert_eq!(response.status(), StatusCode::OK);
let auths: Vec<JwtAuthorizer<User>> = vec![
let auths: [JwtAuthorizer<User>; 2] = [
JwtAuthorizer::from_ec_pem("../config/ecdsa-public1.pem"),
JwtAuthorizer::from_rsa_pem("../config/rsa-public1.pem").jwt_source(JwtSource::Cookie("ccc".to_owned())),
];