In an API controller that extends Controller_Rest
I have in a test function:
public function get_arr_exists($arr = array())
{
if (empty($arr))
{
$this->response(array(), 400);
}
else
{
$this->response(array(), 200);
}
}
I checked rest.php in the fuel core and it requires the first parameter not to be empty else it will return a 404.
But I'd like my app to check if the API responded with ok (200), or not (400). Does the Rest Controller automatically set the status?
Set the response status.
$this->response->status = 200;