I'm creating a REST API in Yii and I'd like to build my URLs like this:
/api/my_model
/api/my_model.xml
/api/my_model.json
Where the first one returns the HTML view, .xml returns XML and .json returns JSON.
This is what I have in the rules for urlManager in main.php:
array('api/list/', 'pattern'=>'api/<model:\w+>', 'verb'=>'GET'),
I figure if I pass a format variable, then if it's blank I know it should return HTML, or json/xml if a format is passed. I tried this:
array('api/list/', 'pattern'=>'api/<model:\w+>.<format:(xml|json)>', 'verb'=>'GET'),
And it works great for .xml and .json, but not when my url is just /api/list
My question is how do I setup the URLs in urlManager to make this work?