/** * Invocation * * Dispatch the middlewares of the route requested * * @param ServerRequestInterface $request Request * @param ResponseInterface $response Response * @param TornadoHttp $next Next Middleware - TornadoHttp container * @return ResponseInterface */ public function __invoke(ServerRequestInterface $request, ResponseInterface $response, TornadoHttp $next) { $index = $next->getMiddlewareIndex(); $routeMiddlewares = $this->routes[$request->getAttribute(Router::REGISTER_KEY)]['middlewares']; foreach ($routeMiddlewares as $middleware) { $next->add($middleware, null, null, null, $index++); } return $next($request, $response); }
* @@@@#, ``.,,.`` | * @@@@@@@@@+:';:,,,.` | * @@@@@@@@@@@@@@@@@@ | * ;@@@@@@@@@@@@@@@ | * '@@@@@@@@@@@` | * ,+@##'` | * @@'` | * '@@@@@@#+;;'# | * @@@@@@@@@@@: | * @@@@@@@@@, | * :@@@@@@@, | * :@@@@@, | * :@@@# | * `@@ | * @ | * | * ---------------------------------- Generated with: http://picascii.com ----------------------------------- | */ namespace App; use DMS\TornadoHttp\TornadoHttp; use Zend\Diactoros\Response; use Zend\Diactoros\ServerRequestFactory; use Zend\ServiceManager\ServiceManager; require '../vendor/autoload.php'; $container = new ServiceManager(require '../src/App/services.php'); $middlewares = (require '../src/App/middlewares.php'); $app = new TornadoHttp($middlewares); $app->setDI($container); $app->setEnvironment($container->get('Config')->environment); $app(ServerRequestFactory::fromGlobals(), new Response());