/** * @param Request $request * @return \Illuminate\Http\Response */ public function handle(Request $request) { try { $response = $this->router->dispatch($request); } catch (NotFoundHttpException $e) { // parse request to return an error according to protocol $response = new Response('Page not found', 404); } catch (MethodNotAllowedHttpException $e) { $response = new Response('Page not found', 404); } $response->sendHeaders(); $response->send(); return $response; }