POST /api/v2/user/current - 405 NOT ALLOWED
This is the correct behavior, because a redirect 302 from
/api/v2/user/current to /api/v1/user/current
is a GET and not a POST request.
In Slim v4 the App::subRequest() method has been removed. You can perform sub-requests via $app->handle($request) from within a route callable.
Example (not tested). This example callable could also be a Action class.
use use Psr\Http\Message\ServerRequestInterface;
// ...
$app->group(
'/v2',
function (Group $group) {
// Internal forward / sub-request
$group->post(
'user/current',
function (ServerRequestInterface $request) use ($app) {
$request = $request->withUri($request->getUri()->withPath('/v1/user/current'));
return $app->handle($request->withMethod('POST'));
}
);
// ...
}
);