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
In our application, we have some clients where we use specific middleware services. We configure them as symfony service. To allow us to configure them in an eightpoints guzzle client, i found no way to do that and ended up writing a plugin. The plugin is so simple that i think it would make sense to integrate it directly into the bundle to allow a configuration section middleware on each client.
if there is interest, i can do a pull request to integrate middleware configuration. but maybe it is not currently supported on purpose?
The whole code for the plugin is this:
use EightPoints\Bundle\GuzzleBundle\PluginInterface;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
/**
* A plugin to allow adding middleware service definitions to clients.
*/
class EightPointsGuzzleMiddlewarePlugin implements PluginInterface
{
public function getPluginName(): string
{
return 'middleware';
}
public function addConfiguration(ArrayNodeDefinition $pluginNode): void
{
$pluginNode->prototype('scalar');
}
public function load(array $configs, ContainerBuilder $container): void
{
}
public function loadForClient(array $config, ContainerBuilder $container, string $clientName, Definition $handler): void
{
foreach ($config as $middleware) {
$handler->addMethodCall('push', [new Reference($middleware)]);
}
}
public function build(ContainerBuilder $container)
{
}
public function boot()
{
}
}
In our application, we have some clients where we use specific middleware services. We configure them as symfony service. To allow us to configure them in an eightpoints guzzle client, i found no way to do that and ended up writing a plugin. The plugin is so simple that i think it would make sense to integrate it directly into the bundle to allow a configuration section
middleware
on each client.if there is interest, i can do a pull request to integrate middleware configuration. but maybe it is not currently supported on purpose?
The whole code for the plugin is this:
and then in the configuration, i can do:
The text was updated successfully, but these errors were encountered: