mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-09-24 02:17:40 +02:00
Allow monitoring/Controller to handle rendering errors while serving JSON or CSV
refs #13623
This commit is contained in:
parent
75ad40f5a3
commit
735a4cb152
@ -25,6 +25,7 @@ class Csv
|
||||
{
|
||||
$csv = new static();
|
||||
$csv->query = $query;
|
||||
$csv->render();
|
||||
return $csv;
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,7 @@ class Json
|
||||
protected function __construct(Traversable $query)
|
||||
{
|
||||
$this->query = $query;
|
||||
$this->render();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -52,6 +52,8 @@ class Controller extends IcingaWebController
|
||||
. '</pre>';
|
||||
exit;
|
||||
case 'json':
|
||||
$json = Json::create($query);
|
||||
|
||||
$response = $this->getResponse();
|
||||
$response
|
||||
->setHeader('Content-Type', 'application/json')
|
||||
@ -65,10 +67,12 @@ class Controller extends IcingaWebController
|
||||
while (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
Json::create($query)->dump();
|
||||
$json->dump();
|
||||
|
||||
exit;
|
||||
case 'csv':
|
||||
$csv = Csv::fromQuery($query);
|
||||
|
||||
$response = $this->getResponse();
|
||||
$response
|
||||
->setHeader('Content-Type', 'text/csv')
|
||||
@ -82,7 +86,7 @@ class Controller extends IcingaWebController
|
||||
while (ob_get_level()) {
|
||||
ob_end_clean();
|
||||
}
|
||||
Csv::fromQuery($query)->dump();
|
||||
$csv->dump();
|
||||
|
||||
exit;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user