use entity::prelude::*; use sea_orm::{ConnectionTrait, DbErr, ModelTrait}; use sea_orm::TransactionTrait; pub struct CorsService; impl CorsService { #[tracing::instrument(skip(connection))] pub async fn check( subdomain: Subdomain, origin: &str, connection: &T, ) -> Result { Ok(subdomain .find_related(CorsEntity) .all(connection) .await .map_err(|cause| { tracing::error!(%cause, "Failed to retrieve origins!"); cause })? .iter() .any(|origin_model| origin_model.matches(origin))) } }