fix: PHP env PSR-7 format — getBody()->write() instead of return array
This commit is contained in:
@@ -450,7 +450,7 @@ function isPrime($n) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function handler(array $ctx): array {
|
function handler($ctx) {
|
||||||
global $CONSTS;
|
global $CONSTS;
|
||||||
$mat = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]];
|
$mat = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]];
|
||||||
$data = range(1, 50);
|
$data = range(1, 50);
|
||||||
@@ -474,7 +474,7 @@ function handler(array $ctx): array {
|
|||||||
'is_prime_97'=> isPrime(97),
|
'is_prime_97'=> isPrime(97),
|
||||||
'groups_3' => groupByMod(array_slice($data, 0, 30), 3),
|
'groups_3' => groupByMod(array_slice($data, 0, 30), 3),
|
||||||
];
|
];
|
||||||
return ['statusCode' => 200, 'body' => json_encode($result)];
|
$ctx["response"]->getBody()->write(json_encode($result));
|
||||||
}
|
}
|
||||||
PHPEOF
|
PHPEOF
|
||||||
create_json "php" "$FN_BIG_PHP" "${TMP}/big_php.php"
|
create_json "php" "$FN_BIG_PHP" "${TMP}/big_php.php"
|
||||||
@@ -564,8 +564,8 @@ function fib($n) {
|
|||||||
if ($n < 2) return $n;
|
if ($n < 2) return $n;
|
||||||
return fib($n-1) + fib($n-2);
|
return fib($n-1) + fib($n-2);
|
||||||
}
|
}
|
||||||
function handler(array $ctx): array {
|
function handler($ctx) {
|
||||||
return ['statusCode' => 200, 'body' => 'cpu-burn-php:' . fib(28)];
|
$ctx["response"]->getBody()->write('cpu-burn-php:' . fib(28));
|
||||||
}
|
}
|
||||||
PHPEOF
|
PHPEOF
|
||||||
create_json "php" "$FN_CPU_PHP" "${TMP}/cpu_php.php"
|
create_json "php" "$FN_CPU_PHP" "${TMP}/cpu_php.php"
|
||||||
@@ -711,8 +711,8 @@ python3 - > "${TMP}/arc-php.zip" << 'EOF'
|
|||||||
import zipfile, io, sys
|
import zipfile, io, sys
|
||||||
buf = io.BytesIO()
|
buf = io.BytesIO()
|
||||||
code = """<?php
|
code = """<?php
|
||||||
function handler(array $ctx): array {
|
function handler($ctx) {
|
||||||
return ['statusCode' => 200, 'body' => json_encode(['tag' => 'archive-php-ok', 'fib25' => 75025])];
|
$ctx[\"response\"]->getBody()->write(json_encode(['tag' => 'archive-php-ok', 'fib25' => 75025]));
|
||||||
}
|
}
|
||||||
"""
|
"""
|
||||||
with zipfile.ZipFile(buf, 'w', zipfile.ZIP_DEFLATED) as zf:
|
with zipfile.ZipFile(buf, 'w', zipfile.ZIP_DEFLATED) as zf:
|
||||||
|
|||||||
Reference in New Issue
Block a user