You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'd like to hear around what you think of an Http::defaultOptions([]);-style method so you can set a few Guzzle options that should be applied to EVERY request that is made during the lifecycle of the application.
My use-case for this would be to configure Guzzle to use a proxy, if a corresponding app config says so. I used this "workaround" before, but this has a lot of downsides and technically it swaps a Factory object (that is requested from the service container) with a PendingRequest object:
$this->app->extend(Factory::class, function (Factory$http, $app) {
if (config('app.request_proxy')) {
return$http->withOptions([
'proxy' => config('app.request_proxy'),
'verify' => false,
]);
}
return$http;
});
To my knowledge there is no easy way to set a bunch of Guzzle settings for every future request, except for overwriting the Factory and doing all the work myself.
My proposal is, and I'm willing to help with the implementation, to create a Http::defaultOptions(array $options) method inside of Factory, that can be used inside the AppServiceProvider i.e. to set default options like the above mentioned proxy setting.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'd like to hear around what you think of an
Http::defaultOptions([]);
-style method so you can set a few Guzzle options that should be applied to EVERY request that is made during the lifecycle of the application.My use-case for this would be to configure Guzzle to use a proxy, if a corresponding app config says so. I used this "workaround" before, but this has a lot of downsides and technically it swaps a Factory object (that is requested from the service container) with a PendingRequest object:
To my knowledge there is no easy way to set a bunch of Guzzle settings for every future request, except for overwriting the Factory and doing all the work myself.
My proposal is, and I'm willing to help with the implementation, to create a
Http::defaultOptions(array $options)
method inside of Factory, that can be used inside the AppServiceProvider i.e. to set default options like the above mentioned proxy setting.Beta Was this translation helpful? Give feedback.
All reactions