Skip to content

Commit 96b4b7a

Browse files
committed
Add discovery support
1 parent fbea623 commit 96b4b7a

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

Diff for: composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"php-http/httplug": "^1.0",
1616
"react/http-client": "^0.4.8",
1717
"react/dns": "^0.4.1",
18-
"react/stream": "^0.4.3"
18+
"react/stream": "^0.4.3",
19+
"php-http/discovery": "^0.8"
1920
},
2021
"require-dev": {
2122
"php-http/adapter-integration-tests": "^0.4"

Diff for: src/Client.php

+7-6
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Http\Adapter\React;
44

5+
use Http\Discovery\MessageFactoryDiscovery;
56
use Psr\Http\Message\ResponseInterface;
67
use React\EventLoop\LoopInterface;
78
use React\Promise\Deferred;
@@ -38,7 +39,7 @@ class Client implements HttpClient, HttpAsyncClient
3839
private $loop;
3940

4041
/**
41-
* HttpPlug message factory.
42+
* HTTPlug message factory.
4243
*
4344
* @var MessageFactory
4445
*/
@@ -47,12 +48,12 @@ class Client implements HttpClient, HttpAsyncClient
4748
/**
4849
* Initialize the React client.
4950
*
50-
* @param MessageFactory $messageFactory
51-
* @param LoopInterface|null $loop React Event loop
52-
* @param ReactClient $client React client to use
51+
* @param MessageFactory|null $messageFactory
52+
* @param LoopInterface|null $loop React Event loop
53+
* @param ReactClient|null $client React client to use
5354
*/
5455
public function __construct(
55-
MessageFactory $messageFactory,
56+
MessageFactory $messageFactory = null,
5657
LoopInterface $loop = null,
5758
ReactClient $client = null
5859
) {
@@ -64,7 +65,7 @@ public function __construct(
6465
$this->loop = (null !== $loop) ?: ReactFactory::buildEventLoop();
6566
$this->client = (null !== $client) ?: ReactFactory::buildHttpClient($this->loop);
6667

67-
$this->messageFactory = $messageFactory;
68+
$this->messageFactory = $messageFactory ?: MessageFactoryDiscovery::find();
6869
}
6970

7071
/**

0 commit comments

Comments
 (0)