src/CsrfMiddleware.php
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $tokenValue = $this->getToken();

        $this->validate($request, $tokenValue);

        // Attach Request Attributes
        $request = $request->withAttribute('csrf_token', $tokenValue);

        /* @var Response $response */
        $response = $handler->handle($request);

        return $this->injectTokenToResponse($response, $tokenValue);
    }
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $tokenValue = $this->getToken();

        $this->validate($request, $tokenValue);

        // Attach Request Attributes
        $request = $request->withAttribute('csrf_token', $tokenValue);

        /* @var Response $response */
        $response = $handler->handle($request);

        return $this->injectTokenToResponse($response, $tokenValue);
    }
public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ handler ) : ResponseInterface { $ tokenValue = $ this -> getToken ( ) ; $ this -> validate ( $ request , $ tokenValue ) ; // Attach Request Attributes $ request = $ request -> withAttribute ( 'csrf_token' , $ tokenValue ) ; /* @var Response $response */ $ response = $ handler -> handle ( $ request ) ; return $ this -> injectTokenToResponse ( $ response , $ tokenValue ) ; }
Invoke middleware.

@param ServerRequestInterface $request The request
@param RequestHandlerInterface $handler The handler

@return ResponseInterface The response
Invoke middleware .