src/Chiron/Http/Middleware/RequestIdMiddleware.php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $uuid = $request->getHeader(self::HEADER_NAME);

        // generate an "unique user id" if not already present.
        if (empty($uuid)) {
            $uuid = $this->uuid();
            $request = $request->withHeader(self::HEADER_NAME, $uuid);
        }

        $response = $handler->handle($request);

        // persist the unique id in the response header list.
        $response = $response->withHeader(self::HEADER_NAME, $uuid);

        return $response;
    }
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $uuid = $request->getHeader(self::HEADER_NAME);

        // generate an "unique user id" if not already present.
        if (empty($uuid)) {
            $uuid = $this->uuid();
            $request = $request->withHeader(self::HEADER_NAME, $uuid);
        }

        $response = $handler->handle($request);

        // persist the unique id in the response header list.
        $response = $response->withHeader(self::HEADER_NAME, $uuid);

        return $response;
    }
public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ handler ) : ResponseInterface { $ uuid = $ request -> getHeader ( self :: HEADER_NAME ) ; // generate an "unique user id" if not already present. if ( empty ( $ uuid ) ) { $ uuid = $ this -> uuid ( ) ; $ request = $ request -> withHeader ( self :: HEADER_NAME , $ uuid ) ; } $ response = $ handler -> handle ( $ request ) ; // persist the unique id in the response header list. $ response = $ response -> withHeader ( self :: HEADER_NAME , $ uuid ) ; return $ response ; }
Add a unique ID for each HTTP request.

@param ServerRequestInterface  $request request
@param RequestHandlerInterface $handler

@return object ResponseInterface
Add a unique ID for each HTTP request .