Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
the around_dispatch hook gets emitted a little earlier
  • Loading branch information
kraih committed Oct 26, 2015
1 parent eb63731 commit 5a32e12
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/Mojolicious.pm
Expand Up @@ -249,6 +249,26 @@ rather advanced features such as upload progress bars possible. Note that this
hook will not work for embedded applications, because only the host application
gets to build transactions. (Passed the transaction and application object)
=head2 around_dispatch
Emitted right after a new request has been received and wraps around the whole
dispatch process, so you have to manually forward to the next hook if you want
to continue the chain. Default exception handling with
L<Mojolicious::Plugin::DefaultHelpers/"reply-E<gt>exception"> is the first hook
in the chain and a call to L</"dispatch"> the last, yours will be in between.
$app->hook(around_dispatch => sub {
my ($next, $c) = @_;
...
$next->();
...
});
This is a very powerful hook and should not be used lightly, it allows you for
example to customize application wide exception handling, consider it the
sledgehammer in your toolbox. (Passed a callback leading to the next hook and
the default controller object)
=head2 before_dispatch
Emitted right before the static file server and router start their work.
Expand Down Expand Up @@ -348,26 +368,6 @@ applications will only work for the application that is rendering.
Useful for rewriting outgoing responses and other post-processing tasks.
(Passed the current controller object)
=head2 around_dispatch
Emitted right before the L</"before_dispatch"> hook and wraps around the whole
dispatch process, so you have to manually forward to the next hook if you want
to continue the chain. Default exception handling with
L<Mojolicious::Plugin::DefaultHelpers/"reply-E<gt>exception"> is the first hook
in the chain and a call to L</"dispatch"> the last, yours will be in between.
$app->hook(around_dispatch => sub {
my ($next, $c) = @_;
...
$next->();
...
});
This is a very powerful hook and should not be used lightly, it allows you for
example to customize application wide exception handling, consider it the
sledgehammer in your toolbox. (Passed a callback leading to the next hook and
the default controller object)
=head1 ATTRIBUTES
L<Mojolicious> inherits all attributes from L<Mojo> and implements the
Expand Down

0 comments on commit 5a32e12

Please sign in to comment.