我使用Zend Expressive作为 API。我已经成功添加了一个中间件,它为每个请求验证 API 密钥的请求标头。
目前我使用 config/pipeline.php 中的 pipe() 函数添加中间件
$app->pipe(new MyAuthMiddleware(....);
这实际上工作得很好。但是,我想使用 Zend Servicemanager 添加管道,而不是使用配置文件,例如:
return [
'dependencies' => [
/* ... */
'invokables' => [
// Remove this entry:
App\Action\HelloAction::class => App\Action\HelloAction::class,
],
'factories' => [
/* ... */
// Add this:
App\Action\HelloAction::class => App\Action\HelloActionFactory::class,
],
/* ... */
],];
问题:是否可以使用 Zend Servicemanager 管理中间件?如果是的话。