https://github.com/bpolaszek/guzzle-duration-middleware
PHP - A GuzzleHTTP Middleware that adds a X-Request-Duration header to all responses to monitor response times.
https://github.com/bpolaszek/guzzle-duration-middleware
Last synced: 9 months ago
JSON representation
PHP - A GuzzleHTTP Middleware that adds a X-Request-Duration header to all responses to monitor response times.
- Host: GitHub
- URL: https://github.com/bpolaszek/guzzle-duration-middleware
- Owner: bpolaszek
- License: mit
- Created: 2017-06-09T09:47:26.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-06-09T11:05:32.000Z (over 8 years ago)
- Last Synced: 2024-10-12T11:15:21.468Z (about 1 year ago)
- Language: PHP
- Size: 2.93 KB
- Stars: 1
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
This package is a middleware for GuzzleHttp 6+ that helps you monitor the time between requests and responses.
Usage
-----
```php
require_once __DIR__ . '/vendor/autoload.php';
use BenTools\GuzzleHttp\Middleware\DurationHeaderMiddleware;
use GuzzleHttp\Client;
$client = new Client();
$middleware = new DurationHeaderMiddleware($headerName = 'X-Request-Duration'); // header name is optional, this is the default value
$client->getConfig('handler')->push($middleware);
$response = $client->get('http://httpbin.org/delay/1');
var_dump((float) $response->getHeaderLine('X-Request-Duration')); // 1.177
```
Installation
------------
```
composer require bentools/guzzle-duration-middleware
```
Tests
-----
```
./vendor/bin/phpunit
```