File: AroundPlugin.pm

package info (click to toggle)
libmojolicious-perl 5.54%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,232 kB
  • ctags: 1,223
  • sloc: perl: 9,581; makefile: 10
file content (18 lines) | stat: -rw-r--r-- 343 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package AroundPlugin;
use Mojo::Base 'Mojolicious::Plugin';

sub register {
  my ($self, $app) = @_;

  # Render return value
  $app->hook(
    around_action => sub {
      my ($next, $c, $action, $last) = @_;
      my $value = $next->();
      $c->render(text => $value) if $last && $c->stash->{return};
      return $value;
    }
  );
}

1;