Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Dancer: Regex route parameter

package App;
use Dancer2;

get '/' => sub {
    return q{
        <a href="/user/foobar-42">foobar</a><br>
    };
};

get '/user/:username[StrMatch[qr{^[a-z]+-[0-9]+$}]]' => sub {
    my $username = route_parameters->get('username');
    return $username;
};

App->to_app;