* Added basic http facade
* Updated build rules
This commit is contained in:
2022-01-06 17:20:40 +01:00
parent 63aae2a504
commit 7c4ca953f6
4 changed files with 31 additions and 7 deletions

View File

@ -122,4 +122,6 @@ function get_filter(string $name, array $args=[]): null|FilterInterface|callable
$filter->setArguments($args);
}
return $filter;
}
}
require_once __DIR__."/http.php";

17
runtime/http.php Normal file
View File

@ -0,0 +1,17 @@
<?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();
}