-
Notifications
You must be signed in to change notification settings - Fork 76
Ability to configure the client by service id. #97
Comments
It's actually already possible to do this, and it is documented in the client configuration documentation page. csa_guzzle:
clients:
github_api:
alias: my_client.service
config:
base_url: https://api.github.com
defaults:
headers:
Accept: application/vnd.github.v3+json 😉 |
Oh, you actually meant being able to specify an existing service defined somewhere else, and configure it using the bundle, right? |
Yes 👍 |
Hum, right now, you can already override the class, if needed, by providing the csa_guzzle:
clients:
github_api:
class: My\Bundle\Client
config:
base_url: https://api.github.com
defaults:
headers:
Accept: application/vnd.github.v3+json |
the idea is, to merge the configuration coming from '_csa_guzzle_' with the |
Hum, this will be complicated, and it may prove difficult to prevent BC on such a feature. I would suggest to take the problem by the other side, by using a compiler pass to extend the original guzzle service, instead, adding additional arguments, method calls, etc. The problem with such a feature is that it may prevent us from implementing other features which I very much want here, like a param converter to inject a response from an API call, and serialization. For this, we need to make sure that the client actually returns what is expected, which is a PSR-7 response or request, or a promise, depending depending on the method being called. |
I thought of a proxy class with a magic method |
Or using https://github.com/Ocramius/ProxyManager ? |
Possible. But in that case, I would actually inject the configured API client, instead. :) |
But regardless, why not! |
ping @Arthurhall |
Any news on this? :) |
I didn't have time to work on it :)
Config example: # config.yml
csa_guzzle:
clients:
github_api:
config:
service: foo.client
base_url: https://api.github.com
overwrite: true # whether overwrite the MyClient config
defaults:
proxy: foo
headers:
Accept: application/vnd.github.v3+json services:
foo.client:
class: Acme\AppBundle\MyClient
arguments: [{proxy: bar}, @baz, %foo.param%]
public: true I don't see how to merge both configurations using the compiler pass? |
I think it is very interesting to have ability to configure a client by service id.
(Using a proxy class for example )
(I can work on)
The text was updated successfully, but these errors were encountered: