Exemplo n.º 1
0
 /**
  * @return callable
  */
 public function create()
 {
     return function (callable $handler) {
         return function (RequestInterface $request, array $options) use($handler) {
             $identifier = $this->resolver->resolve();
             $request = $request->withAddedHeader($this->headerName, (string) $identifier);
             return $handler($request, $options);
         };
     };
 }
 function it_adds_the_request_identifier_in_the_tags(RequestIdentifierResolver $requestIdentifierResolver, RequestIdentifier $identifier)
 {
     $record = ['context' => []];
     $identifier->__toString()->willReturn('1234');
     $requestIdentifierResolver->resolve()->willReturn($identifier);
     $this($record)->shouldReturn(['context' => ['tags' => ['request-identifier' => '1234']]]);
 }
Exemplo n.º 3
0
 function its_middleware_adds_the_header_to_the_request(RequestIdentifierResolver $resolver, RequestInterface $request)
 {
     $identifier = StringRequestIdentifier::fromString('1234');
     $resolver->resolve()->shouldBeCalled()->willReturn($identifier);
     $request->withAddedHeader('X-Request-Id', '1234')->shouldBeCalled();
     $middlewareFactory = $this->create();
     $middleware = $middlewareFactory(function () {
     });
     $middleware($request, []);
 }
 /**
  * Updates the record with the request identifier.
  *
  * @param array $record
  *
  * @return array
  */
 public function __invoke(array $record)
 {
     $record['context']['tags'] = ['request-identifier' => (string) $this->requestIdentifierResolver->resolve()];
     return $record;
 }