adding editing
Deploy / deploy (push) Successful in 8s

This commit is contained in:
2026-05-06 18:23:36 +02:00
parent 3d3895e47b
commit 08df9bfe5c
3 changed files with 74 additions and 12 deletions
+15
View File
@@ -65,6 +65,8 @@ class Router
$path === '/rules' && $method === 'POST' => $this->createRule(),
preg_match('#^/rules/(\d+)$#', $path, $m) && $method === 'DELETE'
=> $this->deleteEntity('rule', (int) $m[1]),
preg_match('#^/rules/(\d+)$#', $path, $m) && $method === 'PUT'
=> $this->updateRule((int) $m[1]),
$path === '/alerts' && $method === 'GET' => $this->getAlerts(),
$path === '/alerts/search' && $method === 'GET' => $this->searchAlerts(),
@@ -185,6 +187,19 @@ class Router
return ['status' => 'deleted', 'id' => $id];
}
private function updateRule(int $id): mixed
{
$body = json_decode(file_get_contents('php://input'), true);
return $this->repo->updateRule(
id: $id,
name: $body['name'],
pattern: $body['pattern'],
severity: $body['severity'] ?? 'warning',
rateLimitSeconds: $body['rate_limit_seconds'] ?? null,
active: $body['active'] ?? true,
);
}
private function getAlerts(): mixed
{
$limit = (int) ($_GET['limit'] ?? 100);