-
Notifications
You must be signed in to change notification settings - Fork 50
Add BaseUriPlugin support. ISSUE-235 #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BaseUriPlugin support. ISSUE-235 #240
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you, looks good!
can you add a documentation pull request and update the CHANGELOG.md file?
(btw, you can edit the pull request to make the description less confusing: remove the example as there is not much to example, remove todos that do not apply etc)
@@ -203,6 +203,13 @@ private function configurePluginByName($name, Definition $definition, array $con | |||
$definition->replaceArgument(1, [ | |||
'replace' => $config['replace'], | |||
]); | |||
case 'base_uri': | |||
$baseService = $serviceId.'.host_uri'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't that be base_uri
?
@dbu yes, I will add. |
->addDefaultsIfNotSet() | ||
->info('Set scheme, host and port in the request URI.') | ||
->children() | ||
->scalarNode('host') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be uri
and not host
IMO, BaseUriPlugin can preprend a path, so someone should be able to use : https://my-site/prepend-path
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
->info('Set scheme, host and port in the request URI.') | ||
->children() | ||
->scalarNode('host') | ||
->info('Host name including protocol and optionally the port number, e.g. https://api.local:8000') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, we should talk about being able to have a path
Thanks for this, can you add also a test in https://github.com/php-http/HttplugBundle/blob/master/Tests/Unit/DependencyInjection/ConfigurationTest.php (Just adding this plugin into the full.yml/xml/php and check if it's equal into the existing test should be enough IMO) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just a few minor changes.
Good work!
->arrayNode('base_uri') | ||
->canBeEnabled() | ||
->addDefaultsIfNotSet() | ||
->info('Set scheme, host and port in the request URI.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe change this to "Set a bast URI to the request-"
->addDefaultsIfNotSet() | ||
->info('Set scheme, host and port in the request URI.') | ||
->children() | ||
->scalarNode('host') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@joelwurtz can you please describe more about this
|
@dbu I also added changes to CHANGELOG.md and PR doc. Can you please review it? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(Just addingthis plugin into the full.yml/xml/php and check if it's equal into the existing test should be enough IMO)
look at the failing tests: there is a unit test called HttplugExtensionTest that checks default and full configuration. here we should make sure that base_uri is supported by adding it to the fixture files for full configuration. (and something seems to go wrong atm, we get an undefined index error - i think its the missing break at the end of the add_host section)
can you please also do a pull request against the documentation to describe how the plugin is configured, and edit the description of this PR to add the link to that PR?
please also add something to the CHANGELOG in a new section "1.9.0 (unreleased)" to say that base_uri support has been added? and finally, because this is a new feature, please change the branch-alias in composer.json to 1.9-dev.
@@ -203,6 +203,13 @@ private function configurePluginByName($name, Definition $definition, array $con | |||
$definition->replaceArgument(1, [ | |||
'replace' => $config['replace'], | |||
]); | |||
case 'base_uri': | |||
$baseService = $serviceId.'.base_uri'; | |||
$this->createUri($container, $baseService, $config['uri']); |
There was a problem hiding this comment.
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)
@@ -203,6 +203,13 @@ private function configurePluginByName($name, Definition $definition, array $con | |||
$definition->replaceArgument(1, [ | |||
'replace' => $config['replace'], | |||
]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing break
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
CHANGELOG.md
Outdated
@@ -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 |
There was a problem hiding this comment.
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."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, the code looks good to me now!
Can you please add this to the full configuration test? see full.yml|xml|php and the configuration test that uses those files.
add_host: |
and please do a pull request to https://github.com/php-http/documentation/blob/master/integrations/symfony-full-configuration.rst to add the example, so that people can discover this functionality.
Added this to full test configuration. And add info to documentation and create new PR.php-http/documentation#226 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you need to add base_uri to full.xml and full.php as well, and adjust Tests/Unit/DependencyInjection/ConfigurationTest.php to expect the base_uri configuration (see the failing test on travis-ci)
CHANGELOG.md
Outdated
@@ -2,6 +2,9 @@ | |||
|
|||
The change log describes what is "Added", "Removed", "Changed" or "Fixed" between each release. | |||
|
|||
## 1.9.0 (unreleased) - 2017-01-12 | |||
- Configured the `BaseUriPlugin` per client, under the `base_uri` configuration key. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'd say: "Allow to configure ..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome. Thank you for this PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I really apprichiate the fix and all the reviews. |
Guys!! Thank you too for support and help and task!!)) |
What's in this PR?
Add BaseUriPlugin support
Why?
#235
Example Usage
http://docs.php-http.org/en/latest/plugins/request-uri-manipulations.html
Checklist