Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function dispatch(CompiledRoute $route, Request $request, &$controller = null)
 {
     $pipeline = new Pipeline($this->container, $route->getMiddleware(), "handle");
     try {
         $response = $pipeline->send($request, function (Request $request) use($route, &$controller) {
             if ($route->usesClosure()) {
                 $controller = $route->getController();
             } else {
                 $controller = $this->createController($route->getControllerName(), $request);
             }
             return $this->callController($controller, $route);
         });
         if ($response === null) {
             // Nothing returned a value, so return a basic HTTP response
             return new Response();
         }
         return $response;
     } catch (PipelineException $ex) {
         throw new RouteException("Failed to dispatch route", 0, $ex);
     }
 }
Beispiel #2
0
 /**
  * Handles an HTTP request
  *
  * @param Request $request The HTTP request to handle
  * @return Response The HTTP response
  */
 public function handle(Request $request)
 {
     try {
         $pipeline = new Pipeline($this->container, $this->getMiddleware(), "handle");
         return $pipeline->send($request, function ($request) {
             return $this->router->route($request);
         });
     } catch (Exception $ex) {
         $this->setExceptionRendererVars($request);
         $this->exceptionHandler->handle($ex);
         return $this->exceptionRenderer->getResponse();
     } catch (Throwable $ex) {
         $this->setExceptionRendererVars($request);
         $this->exceptionHandler->handle($ex);
         return $this->exceptionRenderer->getResponse();
     }
 }