PHP code example of coolblue / http-client-middleware
1. Go to this page and download the library: Download coolblue/http-client-middleware library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
coolblue / http-client-middleware example snippets
declare(strict_types=1);
namespace Coolblue\Http\Client;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
interface MiddlewareInterface
{
public function process(RequestInterface $request, ClientInterface $client): ResponseInterface;
}
$client = new Client(); // an instance of \Psr\Http\Client\ClientInterface
$middlewareOne = new Middleware(); // an instance of \Coolblue\Client\Http\MiddlewareInterface
$middlewareTwo = new Middleware(); // an instance of \Coolblue\Client\Http\MiddlewareInterface
$middlewareClient = new \Coolblue\Http\Client\MiddlewareClient(
$client,
$middlewareOne,
$middlewareTwo
);