Skip to content

Commit f37f0d7

Browse files
authored
Merge pull request #243 from ruudk/query-defaults
Allow to configure the `QueryDefaultsPlugin`
2 parents 2e99696 + b2b9277 commit f37f0d7

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-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

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
$queryDefaultsPlugin = new QueryDefaultsPlugin([
17+
'locale' => 'en'
18+
]);
19+
20+
$pluginClient = new PluginClient(
21+
HttpClientDiscovery::find(),
22+
[$queryDefaultsPlugin]
23+
);
24+

0 commit comments

Comments
 (0)