RestApi: add a new helper method to this trait

This commit is contained in:
Thomas Gelf 2020-10-07 09:25:03 +02:00
parent 9f7568c0ea
commit e2d753bad7
1 changed files with 15 additions and 0 deletions

View File

@ -35,6 +35,21 @@ trait RestApi
}
}
/**
* @return bool
*/
protected function sendNotFoundUnlessRestApi()
{
/** @var \Icinga\Web\Request $request */
$request = $this->getRequest();
if ($request->isApiRequest()) {
return false;
} else {
$this->sendJsonError($this->getResponse(), 'Not found', 404);
return true;
}
}
/**
* @throws AuthenticationException
*/