[英]create extrapattern in yii2
URL : http://localhost/eg_integration/api/web/v1/devices/cacf090690d9dab14df06219ac36b3cd/registrations/pass.usa.gift?passesUpdatedSince=1232 网址: http://localhost/eg_integration/api/web/v1/devices/cacf090690d9dab14df06219ac36b3cd/registrations/pass.usa.gift?passesUpdatedSince = 1232
host : http://localhost/eg_integration/api/web/v1 controller : devices contant term : registrations, passesUpdatedSince 主机: http:// localhost / eg_integration / api / web / v1控制器:设备续称:注册,passedUpdatedSince
Url rule code: 网址规则代码:
'class' => 'yii\rest\UrlRule',
'controller' => 'v1/devices',
'pluralize' => false,
'extraPatterns' => [
'GET registration' => 'getserialnumber',
]
hot to handle this url in extrapattern 可以在Extrapattern中处理此网址
Given that the url is constant, I would set a rule like this: 假设url是常量,我将设置如下规则:
'GET cacf090690d9dab14df06219ac36b3cd/registrations/pass.usa.gift' => 'getserialnumber',
Then in your deviceController you get the query parameter: 然后在deviceController中,获取查询参数:
public function actionGetserialnumber() {
...
$value = Yii::$app->getRequest()->getQueryParam('passesUpdatedSince', $defaultValue)
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.