Dancer2-Plugin-BrowserDetect

 view release on metacpan or  search on metacpan

lib/Dancer2/Plugin/BrowserDetect.pm  view on Meta::CPAN

use Dancer2::Plugin 0.200000;

use HTTP::BrowserDetect ();
use Scalar::Util ();

#ABSTRACT: Provides an easy to have info of the browser.


sub BUILD {
    my $plugin = shift;
    # Create a weakened plugin that we can close over to avoid leaking.
    Scalar::Util::weaken( my $weak_plugin = $plugin );
    $plugin->app->add_hook(
        Dancer2::Core::Hook->new(
            name => 'before_template',
            code => sub {
                my $tokens = shift;
                $tokens->{browser_detect} = $weak_plugin->browser_detect;
            },
        )
    );
}



( run in 0.350 second using v1.01-cache-2.11-cpan-65fba6d93b7 )