NAME

Dancer::Plugin::TimeoutManager - Plugin to define route handlers with a timeout

SYNOPSIS package MyDancerApp;

 use Dancer;
 use Dancer::Plugin::TimeoutManager;
 
 # if somecode() takes more than 1 second, execustion flow will be stoped and a 408 returned
 timeout 1, 'get' => '/method' => sub {
     somecode();
 };

 #if header X-Dancer-Timeout is set, the header's value is used as the timeout
 timeout 'get' => '/method' => sub {
   my $code;
 };

DESCRIPTION

This plugins allows to define route handlers with a maximum amount of time for the code execution.

If that time is elapsed and the code of the route still runs, the execution flow is stopped and a default 408 response is returned.

If the timeout is set to 0, the behavior is the same than without any timeout defined.

It's also possible to define route handlers that will set a per-request timeout protection, depending on the value of the header X-Dancer-Timeout.

AUTHOR

Frederic Lechauve, <frederic_lechauve at yahoo.fr>

COPYRIGHT AND LICENSE

Copyright (C) 2014 by Weborama

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.2 or, at your option, any later version of Perl 5 you may have available.