src/Router.php
protected function wrapMiddleware($path, $middleware)
    {
        return function(
            ServerRequestInterface $request,
            ResponseInterface $response,
            $next
        ) use ($middleware, $path) {
            $uriPath = $request->getUri()->getPath();

            if ($uriPath === $path || strpos($uriPath, rtrim($path, '/') . '/') === 0) {
                $ret = $middleware($request, $response, $next);
            } else {
                $ret = $next($request, $response);
            }
            
            return $ret;
        };
    }
protected function wrapMiddleware($path, $middleware)
    {
        return function(
            ServerRequestInterface $request,
            ResponseInterface $response,
            $next
        ) use ($middleware, $path) {
            $uriPath = $request->getUri()->getPath();

            if ($uriPath === $path || strpos($uriPath, rtrim($path, '/') . '/') === 0) {
                $ret = $middleware($request, $response, $next);
            } else {
                $ret = $next($request, $response);
            }
            
            return $ret;
        };
    }
protected function wrapMiddleware ( $ path , $ middleware ) { return function ( ServerRequestInterface $ request , ResponseInterface $ response , $ next ) use ( $ middleware , $ path ) { $ uriPath = $ request -> getUri ( ) -> getPath ( ) ; if ( $ uriPath === $ path || strpos ( $ uriPath , rtrim ( $ path , '/' ) . '/' ) === 0 ) { $ ret = $ middleware ( $ request , $ response , $ next ) ; } else { $ ret = $ next ( $ request , $ response ) ; } return $ ret ; } ; }
Wrap middleware, so it's only applied to a specified path

@param string   $path
@param callable $middleware
@return callable
Wrap middleware so it s only applied to a specified path