@@ -243,13 +243,13 @@ function (Response $response) use (&$plugin) {
243243
244244 if ($ plugin instanceof WaterPipe) {
245245 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 ,
253253 "patch " => $ plugin ->_patchRequestRegistry ,
254254 "options " => $ plugin ->_optionsRequestRegistry
255255 ] as $ method => $ registry ) {
@@ -475,9 +475,6 @@ private function _findRouteMap()
475475 private function _executeRequest ()
476476 {
477477 try {
478- // Execute middleware
479- self ::triggerBeforeExecuteEvent (Request::capture ());
480-
481478 $ map = $ this ->_findRouteMap ();
482479
483480 if ($ map !== null ) {
@@ -543,12 +540,15 @@ private function _executeRequest()
543540 throw new \Exception ("Malformed route action " );
544541 }
545542
543+ // Execute middleware
544+ self ::triggerBeforeExecuteEvent (Request::capture ());
545+
546546 // NOTE: No code will be executed after this call...
547547 $ this ->_executeAction ($ runner );
548548 } catch (\Exception $ e ) {
549- if (isset ($ this ->_errorsRegistry [500 ]))
549+ if (isset ($ this ->_errorsRegistry [500 ])) {
550550 $ this ->_executeAction ($ this ->_errorsRegistry [500 ]);
551- else {
551+ } else {
552552 $ config = WaterPipeConfig::get ();
553553 if ($ config ->useStderr ()) {
554554 $ stream = fopen ("php://stderr " , 'w ' );
0 commit comments