/**
  * @param ServerRequestInterface $request
  * @param ResponseInterface $response
  * @param callable|null $next
  * @return ResponseInterface
  */
 public function __invoke(ServerRequestInterface $request, ResponseInterface $response, callable $next = null) : ResponseInterface
 {
     $result = $this->router->match($request);
     $request = $this->applyRoutingResult($request, $result);
     if ($next) {
         $response = $next($request->withAttribute($this->routingResultAttribute, $result), $response);
     }
     return $response;
 }