I am trying to route multiple HTTP methods (GET and POST) to display the same content. For instance, I have a register page:
$app->map('/admin/register', function () use ($app) {
$app->render('/admin/register.twig');
})->via('GET', 'POST');
This will display the register form upon GET and POST requests. I then want to specify 'extra stuff' to happen on POST.
$app->map('/admin/register', function () use ($app) {
$app->render('/admin/register.twig');
})->via('GET', 'POST');
$app->post('/admin/register', function () use ($app) {
// Validate register information
});
However, the second function is being ignored. I want to do this so that I can then display error messages above the register form. How would I go about achieving this?