49 lines
875 B
PHP
Raw Normal View History

2024-11-02 15:27:08 +08:00
<?php
use think\exception\HttpResponseException;
$version = request()->post('version');
//var_dump($version);die;
if(!$version){
$version = request()->param('version');
}
app()->http->name('gateway'); #应用
//#设置指定应用的命名空间
app()->setNamespace('app\gateway'); #应用的命名空间
//默认跳转到v1版本
if ($version == null) $version = "api";#api.notify,url
$pathInfo = request()->pathinfo();
if ($pathInfo == null) {
$json = [
'code' => -802,
'data'=>'',
'msg' =>'请求错误'
];
throw new HttpResponseException(json($json));
}
if($version!='api'){
if(!str_contains($pathInfo, 'api.')){
app()->route->any('call','/gateway/api.notify/call');
}
}else{
if(!str_contains($pathInfo, 'api.')){
app()->route->any('call','/gateway/'.$version.'.notify/call');
}
}