Mojolicious::Liteのプレースホルダとパラメータ

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
#!/usr/bin/env perl
use utf8;
use Mojolicious::Lite;

get '/' => sub { shift->redirect_to('/everything/54?name=hoge'); };

get '/everything/:stuff' => [stuff => qr/\d+/] => {stuff => 23} => sub {
    shift->render('welcome');
};

app->log->level('error');
app->start;

__DATA__
@@ welcome.html.ep
Stuff is <%= $stuff %>.
クエリーnameの値は<%= param 'name' %>」です
1
2
3
#!/usr/bin/env perl
use utf8;
use Mojolicious::Lite;
1
get '/' => sub { shift->redirect_to('/everything/54?name=hoge'); };
1
2
3
get '/everything/:stuff' => [stuff => qr/\d+/] => {stuff => 23} => sub {
    shift->render('welcome');
};
1
2
app->log->level('error');
app->start;
1
2
3
4
__DATA__
@@ welcome.html.ep
Stuff is <%= $stuff %>.
クエリーnameの値は<%= param 'name' %>」です
comments powered by Disqus
Built with Hugo
テーマ StackJimmy によって設計されています。