Skip to content

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

Merged
merged 10 commits into from
Feb 13, 2018

Conversation

llaakkkk
Copy link
Contributor

@llaakkkk llaakkkk commented Dec 19, 2017

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Related tickets -
Documentation php-http/documentation#226
License MIT

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

  • Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix
  • Added info about base_uri to documentation

Copy link
Collaborator

@dbu dbu left a 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';
Copy link
Member

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 ?

@llaakkkk
Copy link
Contributor Author

@dbu yes, I will add.

->addDefaultsIfNotSet()
->info('Set scheme, host and port in the request URI.')
->children()
->scalarNode('host')
Copy link
Member

@joelwurtz joelwurtz Dec 19, 2017

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

Copy link
Member

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')
Copy link
Member

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

@joelwurtz
Copy link
Member

joelwurtz commented Dec 19, 2017

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)

Copy link
Member

@Nyholm Nyholm left a 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.')
Copy link
Member

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')
Copy link
Member

Choose a reason for hiding this comment

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

@llaakkkk
Copy link
Contributor Author

llaakkkk commented Dec 28, 2017

@joelwurtz can you please describe more about this

(Just addingthis plugin into the full.yml/xml/php and check if it's equal into the existing test should be enough IMO)

@llaakkkk
Copy link
Contributor Author

@dbu I also added changes to CHANGELOG.md and PR doc. Can you please review it?

Copy link
Collaborator

@dbu dbu left a 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']);
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)

@@ -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?

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
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."

Copy link
Collaborator

@dbu dbu left a 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.

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.

@llaakkkk
Copy link
Contributor Author

Added this to full test configuration. And add info to documentation and create new PR.php-http/documentation#226

Copy link
Collaborator

@dbu dbu left a 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.
Copy link
Collaborator

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 ..."

Copy link
Member

@Nyholm Nyholm left a 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

Copy link
Collaborator

@dbu dbu left a comment

Choose a reason for hiding this comment

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

Thanks!

@dbu dbu merged commit 5ea9284 into php-http:master Feb 13, 2018
@Nyholm
Copy link
Member

Nyholm commented Feb 13, 2018

I really apprichiate the fix and all the reviews.

@llaakkkk
Copy link
Contributor Author

Guys!! Thank you too for support and help and task!!))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants