国产+高潮+在线,国产 av 仑乱内谢,www国产亚洲精品久久,51国产偷自视频区视频,成人午夜精品网站在线观看

定義應(yīng)用中間件后,設(shè)置某個路由則失效

lethe

問題描述

config/middleaware.php中設(shè)置了api應(yīng)用中間件

return [
    'api'=>[
        \app\api\middleware\LogMiddleware::class
    ]
];

然后再設(shè)置api下某個路由時則沒有執(zhí)行這個中間件

/config/route.php

<?php

/**
 * This file is part of webman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author    walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link      http://m.wtbis.cn/
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 */

use core\utils\Json;
use Webman\Route;

//跨域檢測
Route::options('[{path:.+}]', function () {
    return response('');
});

// 加載admin應(yīng)用下的路由配置
require_once app_path('admin/route.php');

// 加載api應(yīng)用下的路由配置
require_once app_path('api/route.php');

//設(shè)置默認(rèn)的路由兜底
Route::fallback(function () {
    return Json::fail('404 not found', [], 404);
});

//關(guān)閉默認(rèn)路由
Route::disableDefaultRoute();

/app/api/route.php

<?php
use app\api\controller\IndexController;
use Webman\Route;

Route::group("/api", function () {
    Route::post('/index/index', [IndexController::class, 'index']);
});

這個api/index/index路由地址沒有執(zhí)行中間件

1235 1 0
1個回答

喵了個咪

有可能有其它中間件攔截了請求,所以沒走api中間件

  • 暫無評論
年代過于久遠,無法發(fā)表回答
??