Answer the question
In order to leave comments, you need to log in
Own method in a controller in a restful application?
Hello everyone, I made a restful application following the official doc .
Tell me, please, how and where can I define a new method "actionLogin" so that it is executed, for example, with such a request - "GET /api/users/login"?
Answer the question
In order to leave comments, you need to log in
I seem to have figured it out:
'urlManager' => [
'enablePrettyUrl' => true,
// 'enableStrictParsing' => true,
'showScriptName' => false,
// here is your backend URL rules
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => ['v1/country', 'v1/menu'],
'tokens' => [
'{id}' => '<id:\\w+>',
],
],
[
'class' => 'yii\rest\UrlRule',
'controller' => ['v1/user'],
'extraPatterns' => [
'GET login' => 'login',
],
]
],
],
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question