getPath()), '/'); $filePath = $this->documentRoot . $requestPath; $documentPath = $filePath; if (! is_file($documentPath)) { $documentPath = $filePath . '/' . $this->indexFile; } if (is_file($documentPath) && str_ends_with($documentPath, '.php')) { try { ob_start(); include $documentPath; $content = ob_get_clean(); $response->setStatusCode(Status::SUCCESS); $response->setBody($content); $response->setMeta('text/gemini; charset=utf-8'); } catch (\Throwable $exception) { $response->setStatusCode(Status::PERMANENT_FAILURE); $response->setMeta($exception); } } else { return parent::__invoke($response, $request); } return $response; } }