diff --git a/CHANGELOG.md b/CHANGELOG.md
index 99f94432..09192a07 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,12 @@
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release.
+## 1.10.0 (unreleased) - 2018-03-09
+
+### Added
+
+- Allow to configure the `AddPathPlugin` per client, under the `add_path` configuration key.
+
## 1.9.0 - 2018-03-06
### Added
diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php
index 8905895f..cb43df30 100644
--- a/DependencyInjection/Configuration.php
+++ b/DependencyInjection/Configuration.php
@@ -298,6 +298,18 @@ private function createClientPluginNode()
->end()
->end()
->end()
+ ->arrayNode('add_path')
+ ->canBeEnabled()
+ ->addDefaultsIfNotSet()
+ ->info('Add a base path to the request.')
+ ->children()
+ ->scalarNode('path')
+ ->info('Path to be added, e.g. /api/v1')
+ ->isRequired()
+ ->cannotBeEmpty()
+ ->end()
+ ->end()
+ ->end()
->arrayNode('base_uri')
->canBeEnabled()
->addDefaultsIfNotSet()
diff --git a/DependencyInjection/HttplugExtension.php b/DependencyInjection/HttplugExtension.php
index 083f3dd4..0186f794 100644
--- a/DependencyInjection/HttplugExtension.php
+++ b/DependencyInjection/HttplugExtension.php
@@ -207,6 +207,12 @@ private function configurePluginByName($name, Definition $definition, array $con
'replace' => $config['replace'],
]);
+ break;
+ case 'add_path':
+ $pathUriService = $serviceId.'.path_uri';
+ $this->createUri($container, $pathUriService, $config['path']);
+ $definition->replaceArgument(0, new Reference($pathUriService));
+
break;
case 'base_uri':
$baseUriService = $serviceId.'.base_uri';
diff --git a/Resources/config/plugins.xml b/Resources/config/plugins.xml
index f0bab813..b9b3f2dc 100644
--- a/Resources/config/plugins.xml
+++ b/Resources/config/plugins.xml
@@ -34,6 +34,9 @@
+
+
+
diff --git a/Tests/Resources/Fixtures/config/full.php b/Tests/Resources/Fixtures/config/full.php
index b3956aed..e1233c8d 100644
--- a/Tests/Resources/Fixtures/config/full.php
+++ b/Tests/Resources/Fixtures/config/full.php
@@ -24,6 +24,11 @@
'host' => 'http://localhost',
],
],
+ [
+ 'add_path' => [
+ 'path' => '/api/v1',
+ ],
+ ],
[
'base_uri' => [
'uri' => 'http://localhost',
diff --git a/Tests/Resources/Fixtures/config/full.xml b/Tests/Resources/Fixtures/config/full.xml
index 95287667..ef9eaba7 100644
--- a/Tests/Resources/Fixtures/config/full.xml
+++ b/Tests/Resources/Fixtures/config/full.xml
@@ -19,6 +19,9 @@
+
+
+
diff --git a/Tests/Resources/Fixtures/config/full.yml b/Tests/Resources/Fixtures/config/full.yml
index a4545541..8b56b9b3 100644
--- a/Tests/Resources/Fixtures/config/full.yml
+++ b/Tests/Resources/Fixtures/config/full.yml
@@ -18,6 +18,9 @@ httplug:
-
add_host:
host: http://localhost
+ -
+ add_path:
+ path: /api/v1
-
base_uri:
uri: http://localhost
diff --git a/Tests/Unit/DependencyInjection/ConfigurationTest.php b/Tests/Unit/DependencyInjection/ConfigurationTest.php
index 13283ab8..52ca3c74 100644
--- a/Tests/Unit/DependencyInjection/ConfigurationTest.php
+++ b/Tests/Unit/DependencyInjection/ConfigurationTest.php
@@ -134,6 +134,12 @@ public function testSupportsAllConfigFormats()
'replace' => false,
],
],
+ [
+ 'add_path' => [
+ 'enabled' => true,
+ 'path' => '/api/v1',
+ ],
+ ],
[
'base_uri' => [
'enabled' => true,
diff --git a/composer.json b/composer.json
index d2f16bbf..a9b4eabf 100644
--- a/composer.json
+++ b/composer.json
@@ -81,7 +81,7 @@
},
"extra": {
"branch-alias": {
- "dev-master": "1.9-dev"
+ "dev-master": "1.10-dev"
}
}
}