diff --git a/integrations/symfony-full-configuration.rst b/integrations/symfony-full-configuration.rst index dcf90ef..76a042b 100644 --- a/integrations/symfony-full-configuration.rst +++ b/integrations/symfony-full-configuration.rst @@ -123,3 +123,7 @@ This page shows an example of all configuration values provided by the bundle. - header_remove: # List of header names to remove headers: ["X-FOO"] + # Sets query parameters to default value if they are not present in the request. + - query_defaults: + parameters: + locale: en diff --git a/plugins/index.rst b/plugins/index.rst index 6874ceb..3788afa 100644 --- a/plugins/index.rst +++ b/plugins/index.rst @@ -20,6 +20,7 @@ request or you can even start a completely new request. This gives you full cont headers history logger + query redirect request-uri-manipulations retry diff --git a/plugins/query.rst b/plugins/query.rst new file mode 100644 index 0000000..5a3bc48 --- /dev/null +++ b/plugins/query.rst @@ -0,0 +1,24 @@ +Query plugin +============ + +Default Query parameters +------------------------ + +The plugin ``QueryDefaultsPlugin`` allows you to define default values for +query parameters. If a query parameter is not set, it will be added. However, if the query parameter +is already present, the request is left unchanged. Names and values must not be URL encoded as this +plugin will encode them:: + + use Http\Discovery\HttpClientDiscovery; + use Http\Client\Common\PluginClient; + use Http\Client\Common\Plugin\HeaderDefaultsPlugin; + + $queryDefaultsPlugin = new QueryDefaultsPlugin([ + 'locale' => 'en' + ]); + + $pluginClient = new PluginClient( + HttpClientDiscovery::find(), + [$queryDefaultsPlugin] + ); +