Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 0b934d6

Browse files
committed
added Psr ResponseInterface check
1 parent 2a10f34 commit 0b934d6

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

doc/book/cookbook/using-middleware-in-dispatch-event.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ As the request and response in 'dispatch' event is a `Zend\Http` Request and Res
2020
namespace Application;
2121

2222
use Application\Middleware\AuthorizationMiddleware;
23+
use Psr\Http\Message\ResponseInterface;
2324
use Zend\Psr7Bridge\Psr7ServerRequest;
2425
use Zend\Psr7Bridge\Psr7Response;
2526

@@ -35,6 +36,10 @@ class Module
3536
$request = Psr7ServerRequest::fromZend($e->getRequest());
3637
$response = Psr7Response::fromZend($e->getResponse());
3738
$result = ($services->get(AuthorizationMiddleware::class))($request, $response, function() {});
39+
40+
if ($result instanceof ResponseInterface) {
41+
return Psr7Response::toZend($result);
42+
}
3843
}, 2);
3944
}
4045
}

0 commit comments

Comments
 (0)