Skip to content

Commit

Permalink
added hook example for choosing a template variant
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 13, 2014
1 parent faf0c70 commit 11e493b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -703,6 +703,13 @@ Same for pre-processing the request.
$c->req->method($method);
});

# Choose template variant based on request headers
$self->hook(before_dispatch => sub {
my $c = shift;
return unless my $agent = $c->req->headers->user_agent;
$c->stash(variant => 'ie') if $agent =~ /Internet Explorer/;
});

Or more advanced extensions to add monitoring to your application.

# Forward exceptions to a web service
Expand Down

0 comments on commit 11e493b

Please sign in to comment.