Skip to content
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ The change log describes what is "Added", "Removed", "Changed" or "Fixed" betwee
- Any third party library using `Http\Client\Common\PluginClientFactory` to create `Http\Client\Common\PluginClient`
instances now gets zero config profiling.
- `Http\HttplugBundle\Collector\Collector::reset()`
- BaseUriPlugin support
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah sorry, you did add to the changelog. however, 1.8 has meanwhile been released. please rebase on master and then move this to a new section for 1.9. lets say something like "Configure the BaseUriPlugin per client, under the base_uri configuration key."


### Changed

Expand Down
16 changes: 16 additions & 0 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,22 @@ private function createClientPluginNode()
->end()
->end()
->end()
->arrayNode('base_uri')
->canBeEnabled()
->addDefaultsIfNotSet()
->info('Set a base URI to the request.')
->children()
->scalarNode('uri')
->info('Base Uri including protocol, optionally the port number and prepend path, e.g. https://api.local:8000/api')
->isRequired()
->cannotBeEmpty()
->end()
->scalarNode('replace')
->info('Whether to replace the host if request already specifies one')
->defaultValue(false)
->end()
->end()
->end()
->arrayNode('header_append')
->canBeEnabled()
->info('Append headers to the request. If the header already exists the value will be appended to the current value.')
Expand Down
7 changes: 7 additions & 0 deletions DependencyInjection/HttplugExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ private function configurePluginByName($name, Definition $definition, array $con
$definition->replaceArgument(1, [
'replace' => $config['replace'],
]);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing break

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you still need to add a break; here, its the reason why the tests fail

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dbu I fixed all review, can you please review my PR?

case 'base_uri':
$baseService = $serviceId.'.base_uri';
$this->createUri($container, $baseService, $config['uri']);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we s/$baseService/$baseUriService/ and refactor the section above (add_host) to call its variable s/$uriService/$hostUriService/? i would prefer consistent naming and being specific helps here (otherwise we have twice $uriService which is confusing too)

$definition->replaceArgument(0, new Reference($uriService));
$definition->replaceArgument(1, [
'replace' => $config['replace'],
]);

break;
case 'header_append':
Expand Down
4 changes: 4 additions & 0 deletions Resources/config/plugins.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@
<argument/>
<argument/>
</service>
<service id="httplug.plugin.base_uri" class="Http\Client\Common\Plugin\BaseUriPlugin" public="false" abstract="true">
<argument/>
<argument/>
</service>
<service id="httplug.plugin.header_append" class="Http\Client\Common\Plugin\HeaderAppendPlugin" public="false" abstract="true">
<argument/>
</service>
Expand Down