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