Closed
Description
Q | A |
---|---|
Bug? | no |
New Feature? | yes |
Actual Behavior
To configure a client with a default host, we can use the AddHostPlugin. However, this plugin can not be configured within HttplugBundle as far as i can see. I ended up doing this:
parameters:
server: "http://localhost:8001"
services:
app.http.todo_hostname_uri:
class: Psr\Http\Message\UriInterface
factory: ["@httplug.uri_factory", createUri]
arguments: ["%server%"]
app.http.plugin.todo_hostname:
class: Http\Client\Common\Plugin\AddHostPlugin
arguments: ["@app.http.todo_hostname_uri"]
httplug:
clients:
todo:
factory: "httplug.factory.guzzle6"
plugins: ["app.http.plugin.todo_hostname", "httplug.plugin.error"]
Possible Solutions
Not sure, but it should be easier than this imo. AddHostPlugin typehints UriInterface, and afaik we can't use a factory for an argument, hence we need to define a service for the uri object.
We could add a configuration in the clients.{name}
space for default_host and force_host but i am not sure how well this scales with other options. maybe an options subsection?