for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Kelemen\ApiNette\Presenter;
use Kelemen\ApiNette\Api;
use Kelemen\ApiNette\Exception\ApiNetteException;
use Nette\Application\UI\Presenter;
use Nette\Http\IResponse;
use Kelemen\ApiNette\Response\JsonApiResponse;
use Tracy\Debugger;
class ApiPresenter extends Presenter
{
/** @var Api */
private $api;
/**
* @param Api $api
*/
public function __construct(Api $api)
parent::__construct();
$this->api = $api;
}
* Run api handling
* @param $params
public function actionDefault($params)
try {
$response = $this->api->run($params);
} catch (ApiNetteException $e) {
Debugger::log($e, 'error');
$response = new JsonApiResponse(IResponse::S500_INTERNAL_SERVER_ERROR, ['error' => 'Internal server error']);
$this->sendResponse($response);