Files
YwxAppThink/app/api/route/route.php
T

29 lines
1.2 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | YwxApp [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2026-2036 http://ywxapp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: ywxapp<admin@ywxapp.cn>
// +----------------------------------------------------------------------
use think\facade\Route;
// 支持批量添加
Route::pattern([
'name' => '\w+',
'id' => '\d+',
]);
// 一级控制器版本化 API/api/v1/...、/api/v2/...
//
// 插件路由(/<插件>/backend、/<插件>/developer、/<插件>/api 等)统一由
// 主应用 ywxapp/service/AppService::loadAddonRoutes() 在 boot 阶段注册,
// 本文件【不再】引入插件 route/app.php——否则 think-multi-app 会把 api 当作
// 应用名截走并叠加前缀,导致 /api/<插件>/* 或 /api/api/* 恒 404。
Route::group(':version', function () {
Route::rule(':Controller/:action', ':version.:Controller/:action');
})->middleware(\think\middleware\AllowCrossDomain::class)->pattern([
'version' => 'v\d+', // 匹配 v1/v2/v3...
]);