@@ -243,13 +243,13 @@ function (Response $response) use (&$plugin) {
243
243
244
244
if ($ plugin instanceof WaterPipe) {
245
245
foreach ([
246
- "request " => $ plugin ->_requestRegistry ,
247
- "get " => $ plugin ->_getRequestRegistry ,
248
- "post " => $ plugin ->_postRequestRegistry ,
249
- "put " => $ plugin ->_putRequestRegistry ,
250
- "error " => $ plugin ->_errorsRegistry ,
251
- "delete " => $ plugin ->_deleteRequestRegistry ,
252
- "head " => $ plugin ->_headRequestRegistry ,
246
+ "request " => $ plugin ->_requestRegistry ,
247
+ "get " => $ plugin ->_getRequestRegistry ,
248
+ "post " => $ plugin ->_postRequestRegistry ,
249
+ "put " => $ plugin ->_putRequestRegistry ,
250
+ "error " => $ plugin ->_errorsRegistry ,
251
+ "delete " => $ plugin ->_deleteRequestRegistry ,
252
+ "head " => $ plugin ->_headRequestRegistry ,
253
253
"patch " => $ plugin ->_patchRequestRegistry ,
254
254
"options " => $ plugin ->_optionsRequestRegistry
255
255
] as $ method => $ registry ) {
@@ -475,9 +475,6 @@ private function _findRouteMap()
475
475
private function _executeRequest ()
476
476
{
477
477
try {
478
- // Execute middleware
479
- self ::triggerBeforeExecuteEvent (Request::capture ());
480
-
481
478
$ map = $ this ->_findRouteMap ();
482
479
483
480
if ($ map !== null ) {
@@ -543,12 +540,15 @@ private function _executeRequest()
543
540
throw new \Exception ("Malformed route action " );
544
541
}
545
542
543
+ // Execute middleware
544
+ self ::triggerBeforeExecuteEvent (Request::capture ());
545
+
546
546
// NOTE: No code will be executed after this call...
547
547
$ this ->_executeAction ($ runner );
548
548
} catch (\Exception $ e ) {
549
- if (isset ($ this ->_errorsRegistry [500 ]))
549
+ if (isset ($ this ->_errorsRegistry [500 ])) {
550
550
$ this ->_executeAction ($ this ->_errorsRegistry [500 ]);
551
- else {
551
+ } else {
552
552
$ config = WaterPipeConfig::get ();
553
553
if ($ config ->useStderr ()) {
554
554
$ stream = fopen ("php://stderr " , 'w ' );
0 commit comments