/** * @return Response */ public function run() { $controller = new Controller($this->resources->request(), $this->resources->storage(), new Direction\Factory()); try { $response = $controller->{$_SERVER['REQUEST_METHOD']}(); $this->invokeCache($response); return $response; } catch (Controller\NotFoundException $e) { return Response::notFound(); } catch (Controller\NotImplementedException $e) { return Response::notImplemented($e->getMessage()); } catch (\Exception $e) { error_log(strval($e)); return Response::serverError(); } }