You are here

public static function Middleware::history in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/guzzle/src/Middleware.php \GuzzleHttp\Middleware::history()

Middleware that pushes history data to an ArrayAccess container.

Parameters

array $container Container to hold the history (by reference).:

Return value

callable Returns a function that accepts the next handler.

1 call to Middleware::history()
ClientTest::getGuzzle in vendor/fabpot/goutte/Goutte/Tests/ClientTest.php

File

vendor/guzzlehttp/guzzle/src/Middleware.php, line 83

Class

Middleware
Functions used to create and wrap handlers with handler middleware.

Namespace

GuzzleHttp

Code

public static function history(array &$container) {
  return function (callable $handler) use (&$container) {
    return function ($request, array $options) use ($handler, &$container) {
      return $handler($request, $options)
        ->then(function ($value) use ($request, &$container, $options) {
        $container[] = [
          'request' => $request,
          'response' => $value,
          'error' => null,
          'options' => $options,
        ];
        return $value;
      }, function ($reason) use ($request, &$container, $options) {
        $container[] = [
          'request' => $request,
          'response' => null,
          'error' => $reason,
          'options' => $options,
        ];
        return new RejectedPromise($reason);
      });
    };
  };
}