Skip to content

Commit e9969bc

Browse files
committed
Better error handling
1 parent 0dff9ea commit e9969bc

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

proxy/proxy.php

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,20 @@ static function (ServerRequestInterface $request) use ($browser): PromiseInterfa
2222
$requests = [];
2323

2424
foreach (explode(',', getenv('URLS')) as $url) {
25-
$requests[] = $browser->get($url . $request->getUri()->getPath() . '?' . $request->getUri()->getQuery());
25+
$requests[] = $browser->get(
26+
$url . $request->getUri()->getPath() . '?' . $request->getUri()->getQuery()
27+
)->then(
28+
static fn (ResponseInterface $response): string => (string)$response->getBody(),
29+
static fn (): string => '',
30+
);
2631
}
2732

28-
return all($requests)->then(function (array $responses) {
33+
return all($requests)->then(function (array $strings) {
2934
$body = '';
3035

31-
/** @var ResponseInterface $response */
32-
foreach ($responses as $response) {
33-
$body .= (string)$response->getBody() . PHP_EOL;
36+
/** @var */
37+
foreach ($strings as $string) {
38+
$body .= $string;
3439
}
3540

3641
return new Response(200, [], $body);

0 commit comments

Comments
 (0)