I'm trying to create a route in Kohana 3.2 that would match URIs like
api/article/get.json
api/article/get/123.xml
api/blogpost/post.json
api/user/get/username.json
So the idea is that I have a sub directory called API where I have all my api controllers, the route matches the controller, the method, a format, and alternatively and id.
I have set the following rout in my application/bootstrap.php
Route::set('api', 'api/<controller>(/<action>(/<id>).<format>)',
array(
'format' => '(xhtml|xml|json|rss|html|php|serialize)',
))
->defaults(array(
'directory' => 'api',
'controller' => 'blogposts',
'action' => 'get',
'format' => 'json',
));
I have played with multiple combinations of this route, but every time I get the following error message for a url like: localhost/api/blogposts/post.json
HTTP_Exception_404 [ 404 ]: The requested URL api/blogposts/post.php was not found on this server.
It seems to me that this should be fine, but I must be doing something wrong.
Help is appreciated.
Onema
EDIT
My default controller is set to be last, just thought I would mention it as I found this post in SO Kohana 3 route not matching