Hello,
I’m trying to achieve a dynamic URL management system for an API.
Right now I have something like this:
array('api/users/list', 'pattern'=>'api/users/list<format:(.xml|.json)>?', 'verb'=>'GET'),
array('api/users/view', 'pattern'=>'api/users/<id:\d+><format:(.xml|.json)>?', 'verb'=>'GET'),
array('api/users/count', 'pattern'=>'api/users/count<format:(.xml|.json)>?', 'verb'=>'GET'),
And I want to have that for users, companies, etc., but I don’t want to do URL filters to every type of data I need.
I think it could be done by doing something like this:
array('api/<controller:\w+>/list', 'pattern'=>'api/<controller:\w+>/list<format:(.xml|.json)>?', 'verb'=>'GET'),
array('api/<controller:\w+>/view', 'pattern'=>'api/entities/<id:\d+><format:(.xml|.json)>?', 'verb'=>'GET'),
array('api/<controller:\w+>/count', 'pattern'=>'api/entities/count<format:(.xml|.json)>?', 'verb'=>'GET'),
But it doesn’t work as this way I’ve wrote.
Any suggestions?