/** * Handle the route. * * @param \Illuminate\Http\Request $request * @param \Luminous\Routing\Route $route * @param array $parameters * @return \Symfony\Component\HttpFoundation\Response * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException */ protected function handleRoute(Request $request, Route $route, array $parameters) { $controller = $route->getController(); $method = $route->getControllerMethod(); if (is_string($controller) && !($controller = $this->app->make($controller))) { throw new NotFoundHttpException(); } if (!method_exists($controller, $method)) { throw new NotFoundHttpException(); } $callback = [$controller, $method]; if ($controller instanceof Controller) { $middleware = $this->gatherMiddlewareClassNames($controller->getMiddlewareForMethod($request, $method)); $maxAge = $controller->maxAge($request, $method); return $this->sendThroughPipeline($middleware, $request, function () use($callback, $parameters, $maxAge) { return $this->call($callback, $parameters, $maxAge); }); } return $this->call($callback, $parameters); }