mirror of
https://gitlab.com/izyim/prototypes/lumen-microservices/microservice-api-gateway.git
synced 2026-09-02 11:24:40 +00:00
initial commit
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Traits;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
|
||||
trait RequestService
|
||||
{
|
||||
|
||||
public function request($method, $requestUrl, $formParams = [], $headers = [])
|
||||
{
|
||||
$client = new Client([
|
||||
'base_uri' => $this->baseUri
|
||||
]);
|
||||
if (isset($this->secret)) {
|
||||
$headers['Authorization'] = $this->secret;
|
||||
}
|
||||
$response = $client->request($method, $requestUrl,
|
||||
[
|
||||
'form_params' => $formParams,
|
||||
'headers' => $headers
|
||||
]
|
||||
);
|
||||
return $response->getBody()->getContents();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user