Add airport overview page and links to it #225
This commit is contained in:
32
app/Support/Http.php
Normal file
32
app/Support/Http.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
/**
|
||||
* Helper for HTTP stuff
|
||||
* @package App\Support
|
||||
*/
|
||||
class Http
|
||||
{
|
||||
/**
|
||||
* Download a URI. If a file is given, it will save the downloaded
|
||||
* content into that file
|
||||
* @param $uri
|
||||
* @param array $opts
|
||||
* @return string
|
||||
*/
|
||||
public static function get($uri, array $opts)
|
||||
{
|
||||
$client = new Client();
|
||||
$response = $client->request('GET', $uri, $opts);
|
||||
|
||||
$body = $response->getBody()->getContents();
|
||||
if ($response->getHeader('content-type') === 'application/json') {
|
||||
$body = \GuzzleHttp\json_decode($body);
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user