mirror of
https://github.com/grocy/grocy.git
synced 2025-08-15 02:04:38 +00:00
Validate all API request as the API is now open for third parties (references #5)
This commit is contained in:
@@ -4,8 +4,25 @@ namespace Grocy\Controllers;
|
||||
|
||||
class BaseApiController extends BaseController
|
||||
{
|
||||
protected function ApiResponse($response)
|
||||
|
||||
public function __construct(\Slim\Container $container)
|
||||
{
|
||||
return json_encode($response);
|
||||
parent::__construct($container);
|
||||
$this->OpenApiSpec = json_decode(file_get_contents(__DIR__ . '/../grocy.openapi.json'));
|
||||
}
|
||||
|
||||
protected $OpenApiSpec;
|
||||
|
||||
protected function ApiResponse($data)
|
||||
{
|
||||
return json_encode($data);
|
||||
}
|
||||
|
||||
protected function VoidApiActionResponse($response, $success = true, $status = 200, $errorMessage = '')
|
||||
{
|
||||
return $response->withStatus($status)->withJson(array(
|
||||
'success' => $success,
|
||||
'error_message' => $errorMessage
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user