php-spark/runtime/http.php
Christopher Vagnetoft 7c4ca953f6 Tweaks
* Added basic http facade
* Updated build rules
2022-01-06 17:20:40 +01:00

18 lines
333 B
PHP

<?php
function fetch(string $url, array $options=[], bool $returnResponse=false) {
$client = new GuzzleHttp\Client();
$method = $options['method'] ?? 'GET';
$response = $client->request($method, $url, $options);
if ($returnResponse) {
return $response;
}
return (string)$response->getBody();
}