Error creating a RESTful API

Greetings,

So I am building this simple RESTful API with 1.1.7’s new feature. In main.php I have added the following rules to the urlManager:


'api/<controller:\w+>' => array('<controller>/index', 'verb'=>'GET'),

'api/<controller:\w+>' => array('<controller>/create', 'verb'=>'POST'),

I expected that Yii would sort the actions according to the HTTP verb.

What happens is that either rule works alone, and even filters the verb, but when I put them together, I get a 404. It’s like when I both rules, Yii can’t decide which one applies.

Am I doing something wrong? I can get a workaround to do this, but I feel that this approach is the most RESTfully and Yiily way to do it.

Thanks!

I’ve corrected release announcement example a few hours ago. Since config is a PHP array, you can’t use two keys with the same name so workaround is to specify rules like this:




array('<controller>/view', 'pattern'=>'<controller:\w>/<id:\d+>', 'verb'=>'GET'),

array('<controller>/update', 'pattern'=>'<controller:\w>/<id:\d+>', 'verb'=>'PUT, POST'),



I thought about that, but then I kept with the example.

Thanks, it now works like a charm. B)