REAPI/app/gateway/route/index.php
mzeros 74b0763e2c refactor(channel): 优化渠道页面并添加宝塔 WAF防火墙配置选项
- 在渠道表单页面添加宝塔 WAF 防火墙配置选项,包括宝塔 IP 地址、接口密钥和防火墙网站域名
- 注释掉渠道列表页面的联系信息列
- 在路由文件中添加空行,提高代码可读性
2024-12-07 12:45:53 +08:00

65 lines
1.3 KiB
PHP

<?php
use think\exception\HttpResponseException;
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
if (str_contains($version, '.')) {
$version = explode('.', $version);
if($version[1] == '0'){
$version = $version[0];
}else{
$version = $version[0].'_'.$version[1];
}
}
$pathInfo = request()->pathinfo();
if ($pathInfo == null) {
$json = [
'code' => -802,
'data'=>'',
'msg' =>'请求错误'
];
throw new HttpResponseException(json($json));
}
if($version!='api'){
if(!str_contains($pathInfo, 'api.')){
if(str_contains($version, '.')){
$versions = str_replace(".", "", $version);
#支持小版本的更新
app()->route->rule(':controller/:function', $versions . '.:controller/:function');
}else{
app()->route->rule(':controller/:function', $version . '.:controller/:function');
}
}
}else{
if(!str_contains($pathInfo, 'api.')){
app()->route->rule(':controller/:function', 'api' . '.:controller/:function');
}
}