-
Notifications
You must be signed in to change notification settings - Fork 56
Add plugin documentation #30
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
Conversation
@@ -1,5 +1,202 @@ | |||
# Plugin System | |||
|
|||
The plugin system will allow to manipulate requests and responses inside a `HttpClient`. | |||
The plugin system allow to manipulate requests and responses inside a `HttpClient`. |
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.
In general: the correct form is aN HTTP Client.
I think plugin docs can go into this PR. |
Ok this PR is based on a branch directly on this repo, if some people want to help to contribute on one of the plugin documentation you are welcome :) |
Will do |
2f2b210
to
b2c1be0
Compare
@@ -1,5 +1,202 @@ | |||
# Plugin System | |||
|
|||
The plugin system will allow to manipulate requests and responses inside a `HttpClient`. | |||
The plugin system allow to manipulate requests and responses inside an `HttpClient`. |
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.
s/allow/allows/
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.
though "manipulate" is a bit misleading, as they are immutable. should we say "to look at requests and responses and replace them if needed"?
very interesting to read how the plugins work! i commented a lot of details, hope you don't mind joel. process: i suggest we wrap up the main section and then merge without each plugin description already in. otherwise we might wait for quite a while until making this available. will also be easier to review the individual plugin docs in separate pull requests plugins: how would a cache plugin work? it would simply not call |
Quite the opposite thanks for the remarks.
👍
Exactly, or return the exception as the promise if an error happens
Yes that exaclty what it's done actually see : https://github.com/php-http/plugins/blob/master/src/RedirectPlugin.php
No it's just call the then method to add behavior when the response is resolved, see the CookiePlugin for example : https://github.com/php-http/plugins/blob/master/src/CookiePlugin.php However there is some case when you need to wait for the promise when you have an underlying request by example (like in the RetryPlugin or RedirectPlugin)
No it's simply define the second callable of the |
ah, still new to promises. makes a lot of sense. can you maybe integrate your answers into the documentation to make things more clear? i guess i am not the only one not familiar with promises, so having more details could help. maybe we should move the "write your own plugin" into its own chapter inside the plugins/ folder. in a way, its the least important, coming after using the existing plugins. it would be cool to show the core code of plugins to explain cases:
|
I am new to promises as well, so expect a few dumb questions @joelwurtz 😜 |
So all things should be good unless there is still remarks ? |
|
||
## Order of plugins | ||
|
||
When you inject an array of plugins into the `PluginClient`, the order of the plugins, injected into the `PluginClient`, matters. |
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.
=> When you inject an array of plugins into the PluginClient
, the order of the plugins matters.
otherwise the phrase is repeating itself
i have a few more grammatical comments, otherwise this looks ready to merge to me. |
5a68680
to
ff1c1b0
Compare
See php-http/plugins#3
Don't know if we need to provide documentation of each plugin here, or if we can do it in another pull request ?