在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í)行中間件