Tweaks
* Added basic http facade * Updated build rules
This commit is contained in:
@ -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
17
runtime/http.php
Normal 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();
|
||||
|
||||
}
|
Reference in New Issue
Block a user