[PHP高可用後端]②③--資料安全解決方案開篇

weixin_34054866發表於2017-11-15
2953340-0dc908335260e96c.png
image.png
2953340-b6956a140216cf59.png
image.png
2953340-516d0a50bc819def.png
image.png
2953340-2585f89ebb73189c.png
image.png
2953340-4c02c4797fb96251.png
image.png

業務相關的請求引數放在body 必須傳的放在header

2953340-fdd46e946530f61c.png
image.png

Common.php

<?php
/**
 * Created by PhpStorm.
 * User: tong
 * Date: 2017/11/15
 * Time: 15:33
 */

namespace app\api\controller;

use think\Controller;

class Common extends Controller
{
    /**
     * 初始化的方法
     */
    protected function _initialize()
    {
        $this->checkRequestAuth();
    }

    /**
     * 檢查每次app請求的資料是否合法
     */
    public function checkRequestAuth()
    {
        //首先需要獲取headers
        $headers=request()->header();
        halt($headers);
    }
}

Test.php

class Test extends Common
2953340-015429b3bf7889f3.png
image.png

相關文章