response->format = \yii\web\Response::FORMAT_JSON; parent::init(); } /** * behaviors * @return array */ public function behaviors() { return ArrayHelper::merge(parent::behaviors(), [ 'bearerAuth' => [ 'class' => \common\filters\auth\BearerAuth::className(), //'class' => \yii\filters\auth\HttpBearerAuth::className(), 'optional' => [ 'token', 'signature', 'test', ], ] ] ); } /** * beforeAction * @return bool * @throws Exception */ public function beforeAction($action) { try { return parent::beforeAction($action); } catch (\Exception $e) { throw new Exception(isset($e->statusCode) ? $e->statusCode : $e->getCode(), $e->getMessage()); } } }