Skip to content

Commit 1781c76

Browse files
committed
The AddHost plugin should take care of the base path
With the following PHP code example: ```php $httpClient = new HttpMethodsClient( new PluginClient(HttpClientDiscovery::find(), [ new AddHostPlugin(UriFactoryDiscovery::find()->createUri('https://logs.domain.com/api')), new ErrorPlugin(), ]), MessageFactoryDiscovery::find() ); $httpClient->get('/users'); ``` The https://logs.domain.com/users URL will be called instead of /api/users. The base path should be kept on this plugin.
1 parent 4493b10 commit 1781c76

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
- Fix Emulated Trait to use Http based promise which respect the HttpAsyncClient interface
1313
- RedirectPlugin: use the full URL instead of the URI to properly keep track of redirects
14-
14+
- AddHostPlugin now keeps the base path of the URI
1515

1616
## 1.2.1 - 2016-07-26
1717

src/Plugin/AddHostPlugin.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public function handleRequest(RequestInterface $request, callable $next, callabl
5656
->withHost($this->host->getHost())
5757
->withScheme($this->host->getScheme())
5858
->withPort($this->host->getPort())
59+
->withPath($this->host->getPath().$request->getUri()->getPath())
5960
;
6061

6162
$request = $request->withUri($uri);

0 commit comments

Comments
 (0)