Code cleanup
This commit is contained in:
parent
8dec7e6040
commit
0cf6a50c3c
3 changed files with 11 additions and 15 deletions
|
@ -162,7 +162,7 @@ App::get('/v1/functions')
|
|||
$base32 = new Base32();
|
||||
$projectIdHash = \rtrim($base32->encode($projectId), '=');
|
||||
$functions = $dbForProject->find('functions', $queries);
|
||||
$functions = \array_map(function(Document $function) use($functionsDomain, $projectIdHash, $base32) {
|
||||
$functions = \array_map(function (Document $function) use ($functionsDomain, $projectIdHash, $base32) {
|
||||
$functionId = $function->getId();
|
||||
$functionIdHash = \rtrim($base32->encode($functionId), '=');
|
||||
$function = $function->setAttribute('url', "{$functionIdHash}-{$projectIdHash}.{$functionsDomain}");
|
||||
|
|
|
@ -67,18 +67,18 @@ App::init()
|
|||
$host = $swooleRequest->header['host'] ?? '';
|
||||
|
||||
// Function Preview
|
||||
if(\str_ends_with($host, App::getEnv('_APP_DOMAIN_FUNCTIONS'))) {
|
||||
if (\str_ends_with($host, App::getEnv('_APP_DOMAIN_FUNCTIONS'))) {
|
||||
// Remove domain from host
|
||||
$previewDomain = App::getEnv('_APP_DOMAIN_FUNCTIONS');
|
||||
$host = \substr($host, 0, -1 * (1 + \strlen($previewDomain))); // +1 for starting dot (.)
|
||||
|
||||
if(empty($host) || \str_contains($host, '.')) {
|
||||
if (empty($host) || \str_contains($host, '.')) {
|
||||
throw new AppwriteException(AppwriteException::ROUTER_INVALID_URL);
|
||||
}
|
||||
|
||||
$ids = explode('-', $host);
|
||||
|
||||
if(\count($ids) !== 2) {
|
||||
if (\count($ids) !== 2) {
|
||||
throw new AppwriteException(AppwriteException::ROUTER_INVALID_URL);
|
||||
}
|
||||
|
||||
|
@ -120,11 +120,11 @@ App::init()
|
|||
|
||||
\curl_close($ch);
|
||||
|
||||
if($errNo !== 0) {
|
||||
if ($errNo !== 0) {
|
||||
return $response->setStatusCode(500)->send("Internal error: " . $error);
|
||||
}
|
||||
|
||||
if($statusCode >= 400) {
|
||||
if ($statusCode >= 400) {
|
||||
$error = \json_decode($executionResponse, true)['message'];
|
||||
return $response->setStatusCode(500)->send("Execution error: " . $error);
|
||||
}
|
||||
|
@ -137,7 +137,7 @@ App::init()
|
|||
|
||||
$body = $execution['body'] ?? '';
|
||||
|
||||
if(($execution['headers']['x-open-runtimes-encoding'] ?? '') === 'base64') {
|
||||
if (($execution['headers']['x-open-runtimes-encoding'] ?? '') === 'base64') {
|
||||
$body = \base64_decode($body);
|
||||
}
|
||||
|
||||
|
@ -150,7 +150,7 @@ App::init()
|
|||
$route = $utopia->getRoute();
|
||||
Request::setRoute($route);
|
||||
|
||||
if($route === null) {
|
||||
if ($route === null) {
|
||||
return $response->setStatusCode(404)->send("Not Found");
|
||||
}
|
||||
|
||||
|
@ -729,7 +729,7 @@ App::get('/.well-known/acme-challenge')
|
|||
include_once __DIR__ . '/shared/api.php';
|
||||
|
||||
App::wildcard()
|
||||
->action(function() {
|
||||
->action(function () {
|
||||
throw new AppwriteException(AppwriteException::GENERAL_ROUTE_NOT_FOUND);
|
||||
});
|
||||
|
||||
|
|
|
@ -236,10 +236,6 @@ class Executor
|
|||
$responseType = $responseHeaders['content-type'] ?? '';
|
||||
$responseStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
|
||||
\var_dump($responseBody);
|
||||
\var_dump($responseStatus);
|
||||
\var_dump($responseHeaders);
|
||||
|
||||
if ($decode) {
|
||||
switch (substr($responseType, 0, strpos($responseType, ';'))) {
|
||||
case 'application/json':
|
||||
|
|
Loading…
Reference in a new issue