<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                實際開發中,后端返回給前端的參數往往都是這樣的。 ![](https://img.kancloud.cn/1a/79/1a7922de6e3ef54dc38330e1c5d87027_297x298.png) 所以我們需要對參數返回形式做個統一的處理 在app目錄下的common.php中定義的方法全局都可調用,所以在這個文件中定義此方法。 ``` <?php use think\Response; // 應用公共文件 // 統一返回數據格式 function result($data = [], string $msg = 'error', int $code = 200, string $type = 'json'):Response { $result = [ "code" => $code, "msg" => $msg, "data" => $data ]; // 調用Response的create方法,指定code可以改變請求的返回狀態碼 return Response::create($result, $type)->code($code); } ``` *app/middleware/CheckToken.php* ``` <?php namespace app\middleware; use thans\jwt\facade\JWTAuth; use thans\jwt\exception\JWTException; class CheckToken { public function handle($request, \Closure $next) { // OPTIONS請求直接返回 if ($request->isOptions()) { return response(); } try { JWTAuth::auth(); }catch (JWTException $e) { return result(null, $e->getMessage(), 401); } return $next($request); } } ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看