PHP code example of tutu-ru / lib-http-request-metadata

1. Go to this page and download the library: Download tutu-ru/lib-http-request-metadata 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/ */

    

tutu-ru / lib-http-request-metadata example snippets


use TutuRu\HttpRequestMetadata\RequestMetadataMiddleware;

// $requestMetadata должен быть создан ранее

$middleware = new RequestMetadataMiddleware($requestMetadata);

use GuzzleHttp\Client;
use GuzzleHttp\HandlerStack;
use GuzzleHttp\Middleware;
use Psr\Http\Message\RequestInterface;
use TutuRu\HttpRequestMetadata\RequestMetadataHandler;

// $requestMetadata должен быть создан ранее

$handlerStack = HandlerStack::create();
$handlerStack->push(Middleware::mapRequest(
    function (RequestInterface $request) use ($requestMetadata) {
        return (new RequestMetadataHandler($requestMetadata))->addToRequest($request);
    }
));
$client = new Client(['handler' => $handlerStack]);