Added two missing headers

This commit is contained in:
Pinga 2023-08-11 01:02:13 +03:00
parent d06b842702
commit e378970764

View file

@ -48,6 +48,7 @@ $http->on('request', function ($request, $response) {
$pdo = new PDO('mysql:host=localhost;dbname=registry', 'registry-select', 'EPPRegistrySELECT');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch (PDOException $e) {
$response->header('Content-Type', 'application/json');
$response->end(json_encode(['error' => 'Error connecting to database']));
return;
}
@ -80,6 +81,7 @@ $http->on('request', function ($request, $response) {
handleSearchQuery($request, $response, $pdo, $searchPattern);
}
else {
$response->header('Content-Type', 'application/json');
$response->status(404);
$response->end(json_encode(['error' => 'Endpoint not found']));
}