I have disabled the default pluralization of my REST rules by setting yii\rest\UrlRule->pluralize = false
and now my UserController is accessible via:
GET user/<id>
-- returns the details of a user by its IDGET user
- returns a list of all usersPOST user
-- create a new user
I want to have second (and only this one) rule to be pluralized, so GET users
returns a list of all users while GET user/<id>
returns the details of a user. How can I achieve this?
I've tried the following:
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => 'user',
'pluralize' => false,
'extraPatterns' => [
'GET users' => 'user',
],
],
But this doesn't work. The user/2
returns given user, the user
return all users, but users
ends up with 404.