Expand description
Dependency injection extractor for Aro actions.
Dep<T> extracts an Arc<T> service from AroState,
enabling type-safe dependency injection in Axum handlers without macro magic.
§Usage in handlers
ⓘ
async fn list_users(
Dep(repo): Dep<dyn UserRepo>,
) -> Result<Json<Vec<User>>, AroError> {
let users = repo.find_all().await?;
Ok(Json(users))
}§Unit testing
Dep<T> can be constructed directly without an HTTP context:
ⓘ
let dep = Dep(Arc::new(MockUserRepo::new()));
let users = dep.find_all().await.unwrap();