2024-09-29 15:43:18 +08:00
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | ThinkAdmin
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | 版权所有 2014~2020 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | 官方网站: https://thinkadmin.top
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | 开源协议 ( https://mit-license.org )
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
|
|
|
|
// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
use think\exception\HttpResponseException;
|
2024-11-02 15:27:08 +08:00
|
|
|
|
|
2024-09-29 15:43:18 +08:00
|
|
|
|
|
|
|
|
|
app()->route->get('api/open/code1','gateway/api.card/add');
|
|
|
|
|
$version = request()->post('version');
|
|
|
|
|
//var_dump($version);die;
|
|
|
|
|
if(!$version){
|
|
|
|
|
$version = request()->param('version');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//默认跳转到v1版本
|
|
|
|
|
if ($version == null) $version = "api";#api.notify,url
|
|
|
|
|
|
|
|
|
|
$pathInfo = request()->pathinfo();
|
|
|
|
|
if ($pathInfo == null) {
|
|
|
|
|
$json = [
|
|
|
|
|
'code' => -802,
|
|
|
|
|
'data'=>'',
|
|
|
|
|
'msg' =>'请求错误'
|
|
|
|
|
];
|
|
|
|
|
// var_dump($json);
|
|
|
|
|
throw new HttpResponseException(json($json));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if($version!='api'){
|
2024-11-02 15:27:08 +08:00
|
|
|
|
if(!str_contains($pathInfo, 'api.')){
|
2024-09-29 15:43:18 +08:00
|
|
|
|
app()->route->rule(':controller/:function', $version . '.:controller/:function');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}else{
|
2024-11-02 15:27:08 +08:00
|
|
|
|
if(!str_contains($pathInfo, 'api.')){
|
2024-09-29 15:43:18 +08:00
|
|
|
|
app()->route->rule(':controller/:function', 'api' . '.:controller/:function');
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|