app->hook(before_dispatch => sub { my ( $c ) = @_; my $url = $c->req->url; my $base = $url->base;# push @{ $base->path }, 'rules'; $base->path->trailing_slash(1); $url->path->leading_slash(0); }); get '/' => sub { my $self = shift; my $host = $self->tx->remote_address; my $content = "Host: $host"; $self->stash(content=>$content); $self->render('index'); }; get '/user' => sub { my $self = shift; my $host = $self->tx->remote_address; my $content = "Host: $host"; $self->stash(content=>$content); $self->render('index'); }; app->start; __DATA__ @@ index.html.ep % layout 'default'; <%== $content %> @@ layouts/default.html.ep Test %= button_to Home => '/' %= button_to User => '/user' %= link_to Home => '/' %= link_to User => 'user' %= content