Skip to content
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 http client router feature #13

Merged
merged 1 commit into from
Mar 30, 2016
Merged

Conversation

joelwurtz
Copy link
Member

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

What's in this PR?

Explained in #12

Checklist

  • Updated CHANGELOG.md to describe BC breaks / deprecations | new feature | bugfix
  • Documentation pull request created (if not simply a bugfix)
  • Add flexible http client #11 Need to be merged before this
  • Matcher should be added in php-http/message (and have some basics implementations)
  • Squash before merge

@sagikazarmark sagikazarmark mentioned this pull request Mar 29, 2016
3 tasks
*
* @author Joel Wurtz <joel.wurtz@gmail.com>
*/
interface RequestMatcher
Copy link
Contributor

Choose a reason for hiding this comment

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

did we not already add a RequestMatcher somewhere?

Copy link
Member

Choose a reason for hiding this comment

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

We did, message. See #14 (comment)

@sagikazarmark sagikazarmark modified the milestone: v1.1.0 Mar 30, 2016
*/
public function addClient($client, RequestMatcher $requestMatcher)
{
$this->clients[] = [
Copy link
Member

Choose a reason for hiding this comment

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

Do you think we could find a better way to store these. Although it's an internal detail, it feels a little but weird.

Copy link
Contributor

Choose a reason for hiding this comment

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

having a member client and a member matcher would make more sense.

re-reading this i am confused about this code. we have a bunch of matcher, but only one single client? if none of the matchers match, we throw an exception, if any matches we always use the same client. that is not what i would expect from a router. i would have expected this to be an array of matcher, client and if a matcher matches, that client is used...

Copy link
Contributor

Choose a reason for hiding this comment

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

the code also indicates that this was originally the idea.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh sorry. i misread the code. it does what i would expect. i don't see how we could store these differently. its a list of pairs [matcher, client] - i would not know how to store that differently. you could try some spl hashmap that can use objects as key if that exists, but i think its quite straightforward.

Copy link
Member

Choose a reason for hiding this comment

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

i would have expected this to be an array of matcher, client and if a matcher matches, that client is used...

I think this is what's happening right now. Isn't it?

That one client is only used as a decorator in order to correctly emulate a client if necessary.

@sagikazarmark
Copy link
Member

Did some improvments. Anyone review?

@dbu
Copy link
Contributor

dbu commented Mar 30, 2016

looks good to me. can we squash the commits a bit?

also, according to the description we have no documentation yet and we should update the changelog.

@sagikazarmark
Copy link
Member

Will do.

@sagikazarmark
Copy link
Member

Changelog updated, doc PR ready.

@sagikazarmark sagikazarmark changed the title [WIP] Add http client router feature Add http client router feature Mar 30, 2016
@sagikazarmark sagikazarmark merged commit 8fc9328 into master Mar 30, 2016
@sagikazarmark sagikazarmark deleted the feature/http-client-router branch March 30, 2016 20:46
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.

HttpClientRouter
3 participants