http://myserver.com/user/func/23
http://myserver.com/user/23
// The magic router() function automatically re-routes
// all HTTP requests to the appropriate REST method.
public function router($res, array $args){
parent::router($res, $args);
switch (Input::method()){
case "GET":
$this->get_index($res,$args);
break;
case "POST":
$this->post_index($res,$args);
break;
case "PUT":
$this->put_index($res,$args);
break;
case "DELETE":
$this->delete_index($res,$args);
break;
default:
// The request uses an unsupported http method
// Handle the error here - i.e.:
$data['error'] = "Unsupported HTTP method request.";
$this->response($data);
}
}
I wanted to see if there was something already 'built-in' in the framework.
I noticed, for instance, that if no $resource is passed in the URI - ie., "http://server.com/monkey/" - then the parent class does put "index" as the $res automatically.
However, "http://server.com/monkey/33' does not automatically route to "get_index" or "post_index", etc., depending on the method. I need to specify "http://server.com/monkey/index/33" instead of just 'http://server.com/monkey/33"...
It seems the only way to get this going is by using custom routing, as shown here. Unless I'm missing something obvious?...
'(:segment)/(:num)' => '$1/item/$2', '(:segment)/(:num)/(:segment)' => '$1/$3/$2',
It looks like you're new here. If you want to get involved, click one of these buttons!