summaryrefslogtreecommitdiff
path: root/src/Server/RequestHandlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/Server/RequestHandlers')
-rw-r--r--src/Server/RequestHandlers/PhpServer.php20
1 files changed, 8 insertions, 12 deletions
diff --git a/src/Server/RequestHandlers/PhpServer.php b/src/Server/RequestHandlers/PhpServer.php
index 5447f72..c3ded4d 100644
--- a/src/Server/RequestHandlers/PhpServer.php
+++ b/src/Server/RequestHandlers/PhpServer.php
@@ -19,23 +19,19 @@ class PhpServer extends DocumentServer
}
if (is_file($documentPath) && str_ends_with($documentPath, '.php')) {
- ob_start();
try {
+ ob_start();
include $documentPath;
- } catch (\Throwable $exception) {
- echo <<<EXCEPTION
-
- ```
- $exception
- ```
+ $content = ob_get_clean();
- EXCEPTION;
+ $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);
}
- $content = ob_get_clean();
- $response->setBody($content);
- $response->setStatusCode(Status::SUCCESS);
- $response->setMeta('text/gemini; charset=utf-8');
} else {
return parent::__invoke($response, $request);
}