Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^7: Dancer2 hook ( Dancer2::Plugin BUILD)

by Anonymous Monk
on Aug 13, 2019 at 02:25 UTC ( [id://11104367]=note: print w/replies, xml ) Need Help??


in reply to Re^6: Dancer2 hook
in thread Dancer2 hook

Hi

That doesn't compile

Also, it is still incomplete

Still, if I go ahead and fill in the blanks by copying  dancer2 -a  HookTest I think I see what you see

You should read https://metacpan.org/pod/Dancer2::Plugin#Writing-the-plugin

This triggers

package TestHook; use Dancer2::Plugin; sub BUILD { my( $plugin ) = @_; $plugin->app->add_route( method => 'get', regexp => '/die', code => sub { die "get '/die' => sub { " }, ); $plugin->app->add_route( method => 'get', regexp => '/ride', code => sub { 'ride' }, ); $plugin->app->add_hook( Dancer2::Core::Hook->new( name => 'after_error', #~ code => sub { $_[0]->content( $_[0]->content . " ... please +?" ) } code => sub { my $content = shift; warn ' From TestHook From TestHook From TestHo +ok From TestHook From TestHook '; $content->{content} .= " hello world From TestHook + "; } )); } 1; __END__

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11104367]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2024-04-26 08:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found