documentRoot = $documentRoot ?: getcwd(); } public function __invoke(Response $response, Request $request): Response { $documentPath = $this->documentRoot . $request->getPath(); if (! is_file($documentPath)) { $documentPath = $this->documentRoot . $request->getPath() . '/index.gmi'; } if (is_file($documentPath)) { $content = file_get_contents($documentPath); $response->setBody($content); $response->setStatusCode(Status::SUCCESS); $response->setMeta(mime_content_type($documentPath) . '; charset=utf-8'); } else { $response->setStatusCode(Status::NOT_FOUND); } return $response; } }