/** * @param ServerRequestInterface $request * @return ResponseInterface */ public function execute(ServerRequestInterface $request) { $this['request'] = $request; $this->registerServiceProviders(); $this->registerControllers($this['router.controllers']); $this->registerFacade(); $this->registerRoutes($router = $this['router']); try { $response = $router->dispatch($request); } catch (HandlerNotFoundException $e) { $response = Response::error404(); } return $response; }