-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
From @basz on November 9, 2017 9:2
To add additional middleware to prooph routes one currently has to add those manually to each defined route.
eg.
[
'name' => 'query::support-doc::list-faqs',
'path' => '/support-doc/categories/{category_id}/faqs',
'middleware' => [
JsonPayload::class,
JsonApiProblem::class,
ResourceServerMiddleware::class,
JsonApiRequestMiddleware::class,
ContentLanguageMiddleware::class,
QueryMiddleware::class,
],
'allowed_methods' => ['GET'],
'options' => ['values' => [QueryMiddleware::NAME_ATTRIBUTE => QueryName::listFaqs]],
],
We could introduce a way so QueryMiddleware and CommandMiddleware are capable of adding arbitrary middlewares so it can be easily configured.
I'm thinking of this configuration bit and some factory modifications;
'prooph' => [
'middleware' => [
'query' => [
'response_strategy' => \HF\Api\ResponseStrategy\JsonApiResponseStrategy::class,
'message_factory' => \HF\Api\Messaging\QueryMessageFactory::class,
'metadata_gatherer' => \HF\Api\Middleware\RequestMetadataGatherer::class,
'middlewares' =>
[
JsonPayload::class,
JsonApiProblem::class,
JsonApiRequestMiddleware::class,
ContentLanguageMiddleware::class,
],
],
'command' => [
'response_strategy' => \HF\Api\ResponseStrategy\JsonApiResponseStrategy::class,
'message_factory' => \HF\Api\Messaging\CommandMessageFactory::class,
'metadata_gatherer' => \HF\Api\Middleware\RequestMetadataGatherer::class,
'middlewares' =>
[
JsonPayload::class,
JsonApiProblem::class,
JsonApiRequestMiddleware::class,
ContentLanguageMiddleware::class,
],
],
...
],
],
These 'middlewares' would need to be fetched from the container by Command and Query Factories and passed to the Command and QueryMiddlewares whom should process them in order and before the MetadataGatherer runs.
Shouldn't be too difficult, thoughts?
Copied from original issue: prooph/psr7-middleware#29
Metadata
Metadata
Assignees
Labels
No labels