Error using Routable class
Closed this issue · 5 comments
I don't know, but I think the problem is that there is no checking of method on Respect\Rest\Routes\Instance.
I have the class:
use Respect\Rest\Routable;
class RoutableImplementation implements Routable
{
public function get()
{
return 'Hi';
}
}
and I declare the route as:
$router->any('/', new RoutableImplementation());
Sending a POST I'm getting the warning:
call_user_func_array() expects parameter 1 to be a valid callback, class 'RoutableImplementation' does not have a method 'POST'
I was expecting a HTTP/1.1 405 Method Not Allowed
with a Allow: GET
.
I'm doing something wrong or that's the expected behavior?
The route is declared to accept any HTTP method.
$router->get('/', new RoutableImplementation());
The validation of methods is made on top of the route declaration, no inference is made on top of the class (or function, or stream) given.
I got your point.
I am of the opinion this still needs a fix, mainly because of the Fatal Error. We have two ways of fixing this:
- returning the 405 as expected
- throwing an exception with a better message (is much better than breaking the whole thing up)
PS: I am +1 for reopening this
Opening again for REST fix with proper HTTP response to specification.
Outdated.
PS.: I'm closing my older issues, please reopen if you think it's relevante.