基础工作非常好:
但是当我尝试使用 DELETE delete (/api/v1/pools/1) 时,我收到以下消息:
不允许的方法
URL /api/v1/pools/1 不允许请求的方法 DELETE。
我什至将 checkAccess() 定义为一个空方法,但似乎没有任何帮助。
设置
控制器:
class PoolController extends \yii\rest\ActiveController
{
public $modelClass = 'api\models\Pool';
public function behaviors()
{
$behaviors = parent::behaviors();
// authenticate by using an access token passed in the username authentication header
$behaviors['authenticator'] = [
'class' => HttpBasicAuth::className(),
];
return $behaviors;
}
}
Run Code Online (Sandbox Code Playgroud)
配置:
....
'urlManager' => [
'enablePrettyUrl' => true,
'showScriptName' => false,
//'enableStrictParsing' => true,
'rules' => [ …Run Code Online (Sandbox Code Playgroud)