Conditions | 3 |
Paths | 4 |
Total Lines | 22 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
21 | public function init() |
||
22 | { |
||
23 | parent::init(); |
||
24 | if (YII_DEBUG) { |
||
25 | $tag = Yii::$app->log->targets['debug']->tag; |
||
26 | $url = getenv('APP_HOST') . 'api/debug/default/view?tag=' . $tag . '&panel=api'; |
||
27 | Yii::$app->response->headers->add('x-debug-tag', $tag); |
||
28 | Yii::$app->response->headers->add('x-debug-url', $url); |
||
29 | } |
||
30 | Yii::$app->response->format = Response::FORMAT_JSON; |
||
31 | Yii::$app->response->headers->add('x-author', 'lianluo.com'); |
||
32 | if (YII_DEBUG) { |
||
33 | Yii::$app->response->headers->add('x-debug-tag', Yii::$app->log->targets['debug']->tag); |
||
34 | } |
||
35 | Yii::$app->user->enableSession = false; |
||
36 | Yii::$app->user->loginUrl = null; |
||
37 | Yii::$app->request->parsers = [ |
||
38 | 'application/json' => 'yii\web\JsonParser', |
||
39 | ]; |
||
40 | //在API接口模块执行严格URL检查 |
||
41 | Yii::$app->urlManager->enableStrictParsing = true; |
||
42 | } |
||
43 | } |
||
44 |