我的 API 中有 2 个控制器。每个都定义了额外的模式。除了在额外模式中定义的用户登录之外,我的所有操作都正常工作。
<?
'urlManager' => [
'enablePrettyUrl' => true,
'enableStrictParsing' => true,
'showScriptName' => false,
'rules' => [
[
'class' => 'yii\rest\UrlRule',
'controller' => [ 'v1/item', 'v1/user'],
'tokens' => [
'{id}' => '<id:\\w+>', //commenting out this token allows login to return
'{type}'=>'<type:\\w+>'
],
'extraPatterns' => [
'POST {id}/image/{type}' => 'image', //from the item controller
'GET login' => 'login' // from the USER controller
]
]
],
],
Run Code Online (Sandbox Code Playgroud)
用户/登录错误也是如此。请注意,它正在寻找 v1/user/view 操作
{
"name": "Not Found",
"message": "Page not …Run Code Online (Sandbox Code Playgroud)