[Dancer-users] Hooks for Dancer::Continuation::* ???

Perlover perlover at perlover.com
Fri Dec 16 16:47:42 CET 2011


I am here again ;-)

I found resolving

In psgi file:

use Dancer::Handler ();
use POSIX qw (LC_ALL setlocale);

my $prevRenderRequest = \&Dancer::Handler::render_request;
my $locale;

*Dancer::Handler::render_request = sub {
    $locale = setlocale(LC_ALL);
    $prevRenderRequest->(@_);
    setlocale(LC_ALL, $locale);
};


I think it's better way for Dancer 1

Best regards!

2011/12/16 Perlover <perlover at perlover.com>:
> Good day!
>
> I used Dancer of 1.3080 & 1.3090 branches
> In my routes i use setlocale for changing locales
>
> I did a following for example:
>
> hook 'before' => sub {
>    $oldLocale = setlocale(LC_ALL);
>    setlocale(LC_ALL, 'ru_RU.UTF-8');
> }
>
> hook 'after' => sub {
>    setlocale(LC_ALL, $oldLocale);
> };
>
> And in my routes i use send_error();
>
> send_error throws an continuation exception and my after hook doesn't
> finish. The  on_handler_exception & on_route_exception will not help
> because their for non continuation exceptions as i understand by view
> sources.
> After requests with send_error() i have an other locale for Starman +
> Dancer process when request in finished. It's bad for me because 1) I
> want to restore ALWAYS my previous locale AFTER ANY ROUTE; 2) And for
> other locales i got other number formats in HTTP response headers for
> example
>
> I didn't find any hooks for continuation exceptions.
> How can i execute my subroutine ALWAYS when any route has finished?
> Even i use a send_error()...
>
> Alexey


More information about the Dancer-users mailing list