1336 links
  • linx
  • Home
  • Login
  • RSS Feed
  • ATOM Feed
  • Tag cloud
  • Picture wall
  • Daily
  • ► Play Videos
Links per page: 20 50 100
page 1 / 1
1 results tagged wildcard x
  • thumbnail
    How to declare a route path with an optional placeholder in Mojolicious::Lite?
    % mojo generate lite_app optional
    ...
    % $EDITOR optional

    One could mark the date as optional by giving it a default value of undef:

    #!/usr/bin/env perl
    use Mojolicious::Lite -signatures;
    
    get '/vote/:value/*when' => { when => undef } => sub ($c) {
        my $value = $c->stash('value');
        my $when  = $c->stash('when');
        $c->render(
            format => 'txt',
            text   => $value . ' ' . ( defined $when ? $when : 'nope' ) . "\n"
        );
    };
    
    app->start;

    which then allows with-or-without the date queries:

    % ./optional get /vote/42 2>/dev/null
    42 nope
    % ./optional get /vote/42/2020/01/07 2>/dev/null
    42 2020/01/07
    % 
    April 28, 2019 at 5:56:41 PM UTC - permalink -
    QRCode
    - https://stackoverflow.com/questions/54170151/how-to-declare-a-route-path-with-an-optional-placeholder-in-mojoliciouslite
    mojolicious parameters placeholder routing wildcard
Links per page: 20 50 100
page 1 / 1
Shaarli - The personal, minimalist, super-fast, database free, bookmarking service by the Shaarli community - Help/documentation