Skip to content

Commit b9ba4fc

Browse files
committed
Response code changed
I think that is better to use 405 as response code in this case. That's because the reason for this error is that the method is not found/allowed. It will be good to have separate cases if method is not declared in the controller and when the HTTP method does not match the expected one. I also purpose to use exclamation mark in the if instead of ```method_exists($this, $controller_method) === FALSE```. It is shorter and since (method_exits())[http://php.net/manual/en/function.method-exists.php] returns boolean, I do not see a problem to do it ;).
1 parent dd5a06d commit b9ba4fc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

application/libraries/REST_Controller.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -660,12 +660,12 @@ public function _remap($object_called, $arguments = [])
660660
}
661661

662662
// Sure it exists, but can they do anything with it?
663-
if (method_exists($this, $controller_method) === FALSE)
663+
if (!method_exists($this, $controller_method))
664664
{
665665
$this->response([
666666
$this->config->item('rest_status_field_name') => FALSE,
667667
$this->config->item('rest_message_field_name') => $this->lang->line('text_rest_unknown_method')
668-
], self::HTTP_NOT_FOUND);
668+
], self::HTTP_METHOD_NOT_ALLOWED);
669669
}
670670

671671
// Doing key related stuff? Can only do it if they have a key right?

0 commit comments

Comments
 (0)