Skip to content

Commit 0360e69

Browse files
committed
Allow to configure the QueryDefaultsPlugin
1 parent 2e99696 commit 0360e69

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

integrations/symfony-full-configuration.rst

+4
Original file line numberDiff line numberDiff line change
@@ -123,3 +123,7 @@ This page shows an example of all configuration values provided by the bundle.
123123
- header_remove:
124124
# List of header names to remove
125125
headers: ["X-FOO"]
126+
# Sets query parameters to default value if they are not present in the request.
127+
- query_defaults:
128+
parameters:
129+
locale: en

plugins/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ request or you can even start a completely new request. This gives you full cont
2020
headers
2121
history
2222
logger
23+
query
2324
redirect
2425
request-uri-manipulations
2526
retry

plugins/query.rst

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Query plugin
2+
==============
3+
4+
Default Query parameters
5+
----------------------
6+
7+
The plugin ``QueryDefaultsPlugin`` allows you to define default values for
8+
query parameters. If a query parameter is not set, it will be added. However, if the query parameter
9+
is already present, the request is left unchanged. Names and values must not be URL encoded as this
10+
plugin will encode them::
11+
12+
use Http\Discovery\HttpClientDiscovery;
13+
use Http\Client\Common\PluginClient;
14+
use Http\Client\Common\Plugin\HeaderDefaultsPlugin;
15+
16+
$defaultUserAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1';
17+
18+
$queryDefaultsPlugin = new QueryDefaultsPlugin([
19+
'locale' => 'en'
20+
]);
21+
22+
$pluginClient = new PluginClient(
23+
HttpClientDiscovery::find(),
24+
[$queryDefaultsPlugin]
25+
);
26+

0 commit comments

Comments
 (0)