-
Notifications
You must be signed in to change notification settings - Fork 57
Provide utility functions for decorating non-standard middleware #136
Provide utility functions for decorating non-standard middleware #136
Conversation
src/functions/double-pass.php
Outdated
* <code> | ||
* $pipeline->pipe(doublePass(function ($req, $handler) { | ||
* // do some work | ||
* }, $responsePrototype)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Closing tag </code>
is missing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed and force pushed update.
cccbd62
to
c7d3fa5
Compare
src/functions/closure.php
Outdated
*/ | ||
function closure(callable $middleware) : Middleware\CallableMiddlewareDecorator | ||
{ | ||
return Middleware\CallableMiddlewareDecorator($middleware); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new
is missing?
src/functions/double-pass.php
Outdated
*/ | ||
function doublePass(callable $middleware, ResponseInterface $response = null) : Middleware\DoublePassMiddlewareDecorator | ||
{ | ||
return Middleware\DoublePassMiddlewareDecorator($middleware, $response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new
is missing?
src/functions/double-pass.php
Outdated
*/ | ||
function doublePass(callable $middleware, ResponseInterface $response = null) : Middleware\DoublePassMiddlewareDecorator | ||
{ | ||
return Middleware\DoublePassMiddlewareDecorator($middleware, $response); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new
is missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great eye! Fixed and pushed!
@weierophinney I feel like the name Also, I'd suggest creating a |
I'm not sure we have much of a need for it within Stratigility itself. Where would you see developers using this, exactly? |
I suppose; if we do, would you have us change the |
`closure()` acts as a convenience wrapper around instantiation of a `CallableMiddlewareDecorator` instance.
`Zend\Stratigility\doublePass` provides a convenience wrapper around creation of a DoublePassMiddlewareDecorator instance.
38de813
to
457a6d3
Compare
- `closure` => `middleware` - `doublePass` => `doublePassMiddleware`
Each is now documented in the API documentation, the migration documentation, and the chapters on middleare creation.
Thanks, @danizord, for the feedback; renamed the functions "middleware" and "doublePassMiddleware". |
Per discussion on #134, this patch provides two utility functions for decorating non-standard middleware.
closure()
allows decorating callables that follow the PSR-15 middleware interface signature via aCallableMiddlewareDecorator
instance:doublePass()
allows decorating callables that follow the double-pass middleware signature (function ($request, $response, callable $next)
) via aDoublePassMiddlewareDecorator
instance:The
doublePass()
function optionally takes a second argument, a response prototype, for use cases where zend-diactoros is not being used as a PSR-7 implementation.TODO