mirror of
https://github.com/yiisoft/yii2.git
synced 2025-11-07 08:27:34 +08:00
Update rest-controllers.md
This commit is contained in:
@ -21,7 +21,7 @@ Yii 提供两个控制器基类来简化创建RESTful
|
|||||||
|
|
||||||
[[yii\rest\ActiveController]] 额外提供一下功能:
|
[[yii\rest\ActiveController]] 额外提供一下功能:
|
||||||
|
|
||||||
* 一系列常用动作: `index`, `view`, `create`, `update`, `delete`, `options`;
|
* 一系列常用动作:`index`,`view`,`create`,`update`,`delete`,`options`;
|
||||||
* 对动作和资源进行用户认证。
|
* 对动作和资源进行用户认证。
|
||||||
|
|
||||||
|
|
||||||
@ -50,12 +50,12 @@ public function actionView($id)
|
|||||||
[[yii\rest\Controller]] 提供的大多数 RESTful API 功能通过[过滤器](structure-filters.md)实现。
|
[[yii\rest\Controller]] 提供的大多数 RESTful API 功能通过[过滤器](structure-filters.md)实现。
|
||||||
特别是以下过滤器会按顺序执行:
|
特别是以下过滤器会按顺序执行:
|
||||||
|
|
||||||
* [[yii\filters\ContentNegotiator|contentNegotiator]]: 支持内容协商,
|
* [[yii\filters\ContentNegotiator|contentNegotiator]]:支持内容协商,
|
||||||
在 [响应格式化](rest-response-formatting.md) 一节描述;
|
在 [响应格式化](rest-response-formatting.md) 一节描述;
|
||||||
* [[yii\filters\VerbFilter|verbFilter]]: 支持HTTP 方法验证;
|
* [[yii\filters\VerbFilter|verbFilter]]:支持 HTTP 方法验证;
|
||||||
* [[yii\filters\auth\AuthMethod|authenticator]]: 支持用户认证,
|
* [[yii\filters\auth\AuthMethod|authenticator]]:支持用户认证,
|
||||||
在[认证](rest-authentication.md)一节描述;
|
在[认证](rest-authentication.md)一节描述;
|
||||||
* [[yii\filters\RateLimiter|rateLimiter]]: 支持频率限制,
|
* [[yii\filters\RateLimiter|rateLimiter]]:支持频率限制,
|
||||||
在[频率限制](rest-rate-limiting.md) 一节描述。
|
在[频率限制](rest-rate-limiting.md) 一节描述。
|
||||||
|
|
||||||
这些过滤器都在 [[yii\rest\Controller::behaviors()|behaviors()]] 方法中声明,
|
这些过滤器都在 [[yii\rest\Controller::behaviors()|behaviors()]] 方法中声明,
|
||||||
@ -122,11 +122,11 @@ public function behaviors()
|
|||||||
|
|
||||||
[[yii\rest\ActiveController]] 默认提供一下动作:
|
[[yii\rest\ActiveController]] 默认提供一下动作:
|
||||||
|
|
||||||
* [[yii\rest\IndexAction|index]]:按页列出资源;
|
* [[yii\rest\IndexAction|index]]:按页列出资源;
|
||||||
* [[yii\rest\ViewAction|view]]:返回指定资源的详情;
|
* [[yii\rest\ViewAction|view]]:返回指定资源的详情;
|
||||||
* [[yii\rest\CreateAction|create]]:创建新的资源;
|
* [[yii\rest\CreateAction|create]]:创建新的资源;
|
||||||
* [[yii\rest\UpdateAction|update]]:更新一个存在的资源;
|
* [[yii\rest\UpdateAction|update]]:更新一个存在的资源;
|
||||||
* [[yii\rest\DeleteAction|delete]]:删除指定的资源;
|
* [[yii\rest\DeleteAction|delete]]:删除指定的资源;
|
||||||
* [[yii\rest\OptionsAction|options]]:返回支持的HTTP方法。
|
* [[yii\rest\OptionsAction|options]]:返回支持的HTTP方法。
|
||||||
|
|
||||||
所有这些动作通过 [[yii\rest\ActiveController::actions()|actions()]] 方法申明,可覆盖 `actions()` 方法配置或禁用这些动作,
|
所有这些动作通过 [[yii\rest\ActiveController::actions()|actions()]] 方法申明,可覆盖 `actions()` 方法配置或禁用这些动作,
|
||||||
|
|||||||
Reference in New Issue
Block a user