21 Jan
2021
21 Jan
'21
5:45 p.m.
On Thu, 21 Jan 2021 17:12:23 +0000 REMORSE@mgh.harvard.edu wrote:
Hi! I'm starting to learn Dancer2. One question I have is whether it is possible to retrieve the current prefix in some way?
I'm not sure whether this is the correct answer, but can you simply use a variable? E.g. my $PREFIX = '/foo';
prefix '/foo';
Becomes "prefix $PREFIX"
get '/' => sub { forward '/foo'; };
Becomes "forward $PREFIX" And so on. Personally I do: prefix '/:name' And then: my $prefix = route_parameters->get('name') But that assumes you want to match multiple prefixes. Andy