getUri(); $path = $uri->getPath(); // If the path does not begin with the version number, prepend v1 by default for retrocompatibility purposes if (strpos($path, '/v') !== 0) { $parts = explode('/', $path); // Remove the first empty part and the array_shift($parts); // Prepend the version prefix array_unshift($parts, '/v1'); $request = $request->withUri($uri->withPath(implode('/', $parts))); } return $out($request, $response); } }