Navigation

Zed Request

This module is used to handle requests from Yves to Zed and the responses from Zed.

Internally it makes use of the well known Guzzle library.

HandlerStackContainer

Guzzle provides a way to add a so called middleware. It makes use of a handler stack where you can push a middleware to. For more details about this checkout the Guzzle handler and middleware documentation.

The HandlerStackContainer can be used to add middleware to the handler stack without touching the AbstractHttpClient.

The HandlerStackContainer holds a static variable where you can add your middle-ware from e.g. a ServiceProvider.

<?php 

namespace Pyz\Yves\YourBundle\Plugin\ServiceProvider;

class YourServiceProvider extends AbstractPlugin implements ServiceProviderInterface
{
    ...
    public function boot(Application $app)
    {
        $handlerStackContainer = $this->getFactory()->createHandlerStackContainer();
        $handlerStackContainer->addMiddleware($this->getFactory()->createYourMiddlewarePlugin());
    }
    ...
}

This technique is used for logging requests sent from Yves to Zed and the responses returned from Zed.

For more details you can look into the ZedRequestLogServiceProvider class.

Your middleware needs to implement MiddlewareInterface which has two simple methods MiddlewareInterface::getName() and MiddlewareInterface::getCallable().