在config/middleaware.php
中設置了api
應用中間件
return [
'api'=>[
\app\api\middleware\LogMiddleware::class
]
];
然后再設置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://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應用下的路由配置
require_once app_path('admin/route.php');
// 加載api應用下的路由配置
require_once app_path('api/route.php');
//設置默認的路由兜底
Route::fallback(function () {
return Json::fail('404 not found', [], 404);
});
//關閉默認路由
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í)行中間件