Skip to content

Commit c29bfde

Browse files
committed
Request URI Manipulations
1 parent a484ddb commit c29bfde

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

plugins/request-uri-manipulations.rst

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Request URI Manipulations
2+
=========================
3+
4+
Request URI manipulations can be done thanks to several plugins:
5+
6+
* ``AddHostPlugin``: Sets default host, scheme and port of each request.
7+
* ``AddPathPlugin``: Sets default base path of each request.
8+
* ``BaseUriPlugin``: Is a combination of ``AddHostPlugin`` and ``AddPathPlugin`` using the ``UriInterface`` class.
9+
10+
Each plugin use the ``UriInterface`` to build the base request::
11+
12+
use Http\Discovery\HttpClientDiscovery;
13+
use Http\Discovery\UriFactoryDiscovery;
14+
use Http\Client\Common\PluginClient;
15+
use Http\Client\Common\Plugin\BaseUriPlugin;
16+
17+
$plugin = new BaseUriPlugin(UriFactoryDiscovery::find()->createUri('https://domain.com:8000/api'), [
18+
// Always replace the host, even if this one is provided on the sent request. Available for AddHostPlugin.
19+
'replace' => 'true',
20+
]));
21+
22+
$pluginClient = new PluginClient(
23+
HttpClientDiscovery::find(),
24+
[$plugin]
25+
);

0 commit comments

Comments
 (0)