#### 问题描述
在`config/middleaware.php`中设置了`api`应用中间件
```
return [
'api'=>[
\app\api\middleware\LogMiddleware::class
]
];
```
然后再设置`api`下某个路由时则没有执行这个中间件
`/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://www.workerman.net/
* @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`路由地址没有执行中间件