[dancer-users] Before Hook hit multiple times.

Rick Bragg rbragg at gmnet.net
Wed Jan 2 22:16:17 GMT 2013


Hi, Is it OK to top-post in this list?  anyway,

I hit the site using chrome.  I think that's really weird to call the before hook a
bunch of times depending on the browser.  Does that mean it will call the before
hook for every resource on every page?  That's useless.  I would expect that all
hooks and routes are called once in the application flow.  Do I really have to
program around this taking into consideration the number of times the before hook
is called on each page?

Rick



> Hello,
>
> First of all, how are you doing your hits? If you use a browser, like
> Firefox, chances are that it will request favicon.ico at each requests,
> hence you'll see at least 2 hits.
>
> Also, it's possible that a HEAD request is done before the real GET
> request, depends on the browser.
>
> For testing purposes, I strongly sugesst using curl to send exactly one
> request:
>
>   $ curl -i http://0:3000/some_route
>
> Cheers,
>
>
> 2013/1/2 Rick Bragg <rbragg at gmnet.net>
>
>> Hi,
>>
>> I put a simple test in my before hook:
>>
>> hook 'before' => sub {
>>         debug "Before Hook";
>> };
>>
>> and a couple of quick routes:
>>
>> #Home Page
>> get '/' => sub { template 'index'; };
>>
>> #About Us page
>> get '/about-us' => sub { template 'about-us'; };
>>
>> (I am also using Auth::Extensible)
>>
>> Whenever I hit the home page, I get 3 debug messages in a row in the log.
>> Whenever I hit the about-up page, I get 2 debug messages in a row in the
>> log.
>>
>> I thought that any kind of page hook would only be called once.  Does
>> anybody know
>> why the before hook would ever be called more than once?
>>
>> Rick
>>
>>
>>
>>
>>
>>
>>
>> _______________________________________________
>> dancer-users mailing list
>> dancer-users at dancer.pm
>> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>>
>>
>
>
> _______________________________________________
> dancer-users mailing list
> dancer-users at dancer.pm
> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
>






More information about the dancer-users mailing list