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

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

lethe

問(wèn)題描述

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

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

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

/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://wtbis.cn/
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 */

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

//跨域檢測(cè)
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']);
});

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

1148 1 0
1個(gè)回答

喵了個(gè)咪

有可能有其它中間件攔截了請(qǐng)求,所以沒(méi)走api中間件

  • 暫無(wú)評(píng)論
年代過(guò)于久遠(yuǎn),無(wú)法發(fā)表回答
??