tommyseus/guzzlehttp-middleware
Composer 安装命令:
composer require tommyseus/guzzlehttp-middleware
包简介
The library provides several middleware classes for the guzzle http client.
README 文档
README
The library provides several middleware classes for the guzzle http client.
Installation
Requirements
- PHP 7.1+
Composer installation
$ composer require tommyseus/guzzlehttp-middleware
Encoding Middleware
The encoding middleware converts the response to the expected encoding. It will modify the body and the content-type header of the response. It's possible to to add the encoding middleware to the handler stack or add it to the promise-then method.
$stack = \GuzzleHttp\HandlerStack::create(); $stack->push(\GuzzleHttp\Middleware::mapResponse(new \Seus\GuzzleHttp\Middleware\Encoding('UTF-8'))); return new \GuzzleHttp\Client([ 'handler' => $stack, ]);
/* @var $client \GuzzleHttp\Client */ $promise = $client->requestAsync('GET', '......'); $promise->then(new \Seus\GuzzleHttp\Middleware\Encoding('UTF-8')); $promise->then( function (\Psr\Http\Message\ResponseInterface $res) { echo $res->getStatusCode(); } ); $promise->wait();
Run tests
$ docker-compose run guzzlehttp-middleware-php72 composer check $ docker-compose run guzzlehttp-middleware-php71 composer check
统计信息
- 总下载量: 234
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-11-12