Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
added another hook example
  • Loading branch information
kraih committed Dec 16, 2014
1 parent 2adf68b commit 4c677d5
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/Mojolicious/Guides/Routing.pod
Expand Up @@ -669,14 +669,20 @@ especially for plugins.

1;

Post-processing the response to set additional headers is a very common use.
Post-processing the response to add or remove headers is a very common use.

# Make sure static files are cached
$app->hook(after_static => sub {
my $c = shift;
$c->res->headers->cache_control('max-age=3600, must-revalidate');
});

# Remove a default header
$app->hook(after_dispatch => sub {
my $c = shift;
$c->res->headers->remove('Server');
});

Same for pre-processing the request.

# Allow "_method" query parameter to override request method
Expand Down

0 comments on commit 4c677d5

Please sign in to comment.