Created
December 8, 2010 12:26
-
-
Save yko/733217 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This action will render a template | |
sub welcome { | |
my $c = shift; | |
# Set url to current. Change to whatever you want | |
my $path = $c->url_for('current'); | |
# Create and set up match object | |
my $m = Mojolicious::Routes::Match->new($c, $path); | |
# Find $path in routes | |
$m->match($c->app->routes); | |
# $m->endpoint now contain endpoint (last matched) route | |
# if path was successfully matched | |
# Render template "example/welcome.html.ep" with message | |
$c->render(message => 'Current route name is: ' | |
. $c->match->endpoint->name | |
. "\n" | |
. 'Custom path matched route: ' | |
. ($m->endpoint ? $m->endpoint->name : 'NO MATCH')); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment