This is a weird one, and I have started noticing this only recently, so perhaps 
with one of the recent updates. Here are the logs (trimmed for sanity)

        12:55:54-punkish~/Projects/punkish (master)$ bin/app.pl
        >> Dancer 1.3115 server 183 listening on http://0.0.0.0:3000
        >> Dancer::Plugin::Ajax (1.00)
        == Entering the development dance floor ...
        [183] debug @0.003543> [hit #2]sending back first-page in 
/path/to/app/lib/punkish.pm l. 34
        [183] debug @0.012338> [hit #4]sending back second-page in 
/path/to/app/lib/punkish.pm l. 34
        [183] debug @0.003169> [hit #5]sending back second-page in 
/path/to/app/lib/punkish.pm l. 34
        [183] debug @0.003327> [hit #8]sending back second-page in 
/path/to/app/lib/punkish.pm l. 34
        [183] debug @0.003521> [hit #11]sending back first-page in 
/path/to/app/lib/punkish.pm l. 34

The app itself is rather simple

        # ajax request
        get '/p/:uri' => sub {
                debug "sending back $uri";
                ..
                return to_json $result;
        };
        
        # If the URI has no /p/ in it then it is a non-ajax call.
        # Send back an empty template and the name of the page
        # to be called via ajax
        
        # !get '/*?'
        get '/*?' => sub {

                ..
                return template 'index', $result, { layout => 'main' };
        }

If the user enters a full path in the browser, Dancer sends back the template 
with the name of the actual page to be loaded which is then called via with the 
/p/ in the path. If Dancer sees /p/ in the path then it sends back only the 
specific page's content. This is my home-grown version of a "single-page-app" 
that all the cool kids are making nowadays, except I am not yet ready to jump 
ship to Nodejs.

The problem is, the first load happens fine. The ajax calls after that just 
hang. As you can see from the log above, the ajax call to 
http://localhost:3000/first-pagehappened fine, but after that, 3 consecutive 
requests to http://localhost:3000/second-page got hung up, and then suddenly, 
as if a plug had been removed, three of them were sent back.

I also tried a direct `curlhttp://localhost:3000/p/second-page` and that too 
just hung.

What is going on?

Oh, and I have a corollary question -- is it possible to customize that debug 
message? For example, instead of the rather unhelpful (to me) 

        [183] debug @0.003543> [hit #2]sending back first-page in 
/path/to/app/lib/punkish.pm l. 34 

I would like to see something like 

        Jun 26, 2013 13:18:23 - sending back first-page in 
/path/to/app/lib/punkish.pm l. 34

In fact, the actual `path/to/app` is really long in my case. I would like to 
just trim that.

Many thanks,

--
Puneet Kishor
_______________________________________________
dancer-users mailing list
[email protected]
http://lists.preshweb.co.uk/mailman/listinfo/dancer-users

Reply via email to