add platform FG
parent
243f08f0fa
commit
d2cdce4277
46
index.php
46
index.php
|
@ -8,8 +8,9 @@ include 'common.php';
|
||||||
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
if (isset($_SERVER['USER'])&&$_SERVER['USER']==='qcloud') {
|
||||||
include 'platform/TencentSCF.php';
|
include 'platform/TencentSCF.php';
|
||||||
} elseif (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
|
} elseif (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
|
||||||
//echo '<pre>'. json_encode($_SERVER, JSON_PRETTY_PRINT).'</pre>';
|
|
||||||
include 'platform/AliyunFC.php';
|
include 'platform/AliyunFC.php';
|
||||||
|
} elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
|
||||||
|
include 'platform/HuaweiFG.php';
|
||||||
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
|
} elseif (isset($_SERVER['HEROKU_APP_DIR'])&&$_SERVER['HEROKU_APP_DIR']==='/app') {
|
||||||
include 'platform/Heroku.php';
|
include 'platform/Heroku.php';
|
||||||
$path = getpath();
|
$path = getpath();
|
||||||
|
@ -56,19 +57,22 @@ function main_handler($event, $context)
|
||||||
return main($path);
|
return main($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Aliyun FC
|
// Aliyun FC & Huawei FG
|
||||||
function handler($request, $context)
|
function handler($event, $context)
|
||||||
{
|
{
|
||||||
|
if (isset($_SERVER['FC_SERVER_PATH'])&&$_SERVER['FC_SERVER_PATH']==='/var/fc/runtime/php7.2') {
|
||||||
|
// Aliyun FC
|
||||||
set_error_handler("myErrorHandler");
|
set_error_handler("myErrorHandler");
|
||||||
$event = array(
|
$tmp = array(
|
||||||
'method' => $request->getMethod(),
|
'method' => $event->getMethod(),
|
||||||
'clientIP' => $request->getAttribute("clientIP"),
|
'clientIP' => $event->getAttribute("clientIP"),
|
||||||
'requestURI' => $request->getAttribute("requestURI"),
|
'eventURI' => $event->getAttribute("eventURI"),
|
||||||
'path' => spurlencode($request->getAttribute("path"), '/'),
|
'path' => spurlencode($event->getAttribute("path"), '/'),
|
||||||
'queryString' => $request->getQueryParams(),
|
'queryString' => $event->getQueryParams(),
|
||||||
'headers' => $request->getHeaders(),
|
'headers' => $event->getHeaders(),
|
||||||
'body' => $request->getBody()->getContents(),
|
'body' => $event->getBody()->getContents(),
|
||||||
);
|
);
|
||||||
|
$event = $tmp;
|
||||||
$context = json_decode(json_encode($context), true);
|
$context = json_decode(json_encode($context), true);
|
||||||
printInput($event, $context);
|
printInput($event, $context);
|
||||||
unset($_POST);
|
unset($_POST);
|
||||||
|
@ -81,6 +85,25 @@ function handler($request, $context)
|
||||||
$re = main($path);
|
$re = main($path);
|
||||||
|
|
||||||
return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], $re['body']);
|
return new RingCentral\Psr7\Response($re['statusCode'], $re['headers'], $re['body']);
|
||||||
|
|
||||||
|
} elseif ($_SERVER['_APP_SHARE_DIR']=='/var/share/CFF/processrouter') {
|
||||||
|
// Huawei FG
|
||||||
|
global $contextUserData;
|
||||||
|
$contextUserData = $context;
|
||||||
|
$event = json_decode(json_encode($event), true);
|
||||||
|
if ($event['isBase64Encoded']) $event['body'] = base64_decode($event['body']);
|
||||||
|
|
||||||
|
printInput($event, $context);
|
||||||
|
unset($_POST);
|
||||||
|
unset($_GET);
|
||||||
|
unset($_COOKIE);
|
||||||
|
unset($_SERVER);
|
||||||
|
GetGlobalVariable($event);
|
||||||
|
//echo '<pre>'. json_encode($_COOKIE, JSON_PRETTY_PRINT).'</pre>';
|
||||||
|
$path = GetPathSetting($event, $context);
|
||||||
|
|
||||||
|
return main($path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// used by Aliyun FC
|
// used by Aliyun FC
|
||||||
|
@ -105,6 +128,5 @@ function myErrorHandler($errno, $errstr, $errfile, $errline) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't execute PHP internal error handler */
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue