I am trying to catch a route with regular expressions in Mojolicious Lite.
This is the route:
get qr!/messages/read/(.*).json! => sub {
my $id = $1;
my $c = shift;
return $c->render(json => { $id => 1 });
};
It just returns page not found. I was wondering if I was missing a plugin or something has changed but I can't find anything.
I tried some variations, like adding a ^ before the first slash, or changing the character after qr but I couldn't make it work.
Thank you for your time.
Mojolicious routes are not regular expressions, so I'm curious what led you to believe you could do this. It looks like you want a placeholder.
get '/messages/read/<:id>.json' => sub {
my $c = shift;
my $id = $c->param('id');
return $c->render(json => { $id => 1 });
};