@@ -73,6 +73,8 @@ class Router
|
||||
preg_match('#^/alerts/counts$#', $path) && $method === 'GET'
|
||||
=> $this->repo->getAlertCounts(),
|
||||
|
||||
$path === '/logs/search' && $method === 'GET' => $this->searchLogs(),
|
||||
|
||||
$path === '/config/allowed_tokens' && $method === 'GET'
|
||||
=> ['tokens' => $this->repo->getAllowedUserTokens()],
|
||||
$path === '/config/allowed_tokens' && $method === 'PUT'
|
||||
@@ -204,6 +206,17 @@ class Router
|
||||
return $this->repo->searchAlerts($query, $limit);
|
||||
}
|
||||
|
||||
private function searchLogs(): array
|
||||
{
|
||||
$query = $_GET['q'] ?? '';
|
||||
if (empty($query)) {
|
||||
return ['data' => []];
|
||||
}
|
||||
$limit = (int) ($_GET['limit'] ?? 200);
|
||||
$offset = (int) ($_GET['offset'] ?? 0);
|
||||
return ['data' => $this->repo->searchLogEntries($query, $limit, $offset)];
|
||||
}
|
||||
|
||||
private function updateAllowedTokens(): array
|
||||
{
|
||||
$body = json_decode(file_get_contents('php://input'), true);
|
||||
|
||||
Reference in New Issue
Block a user