Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Cannot programmatically apply middlewares? #760
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
karenetheridge
Mar 21, 2012
Opened as per irc:
16:58 <@franck> ether: can you report a bug for this on dancer ? I think the doc is incorrect
16:59 <@franck> if you can copy/paste what you're trying to do, I'll take a look later at this
karenetheridge
commented
Mar 21, 2012
Opened as per irc:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
karenetheridge
Mar 21, 2012
PS. It looks like the plack_middlewares setting is only looked at by Dancer::Handler::PSGI. So could it be that my script is using a different handler? How do I get PSGI back into the mix?
karenetheridge
commented
Mar 21, 2012
PS. It looks like the plack_middlewares setting is only looked at by Dancer::Handler::PSGI. So could it be that my script is using a different handler? How do I get PSGI back into the mix? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
karenetheridge
Mar 21, 2012
Ok, I sourcedived some more and found that explicitly setting $ENV{PLACK_ENV} would force the PSGI handler to be used (I'm skeptical that this is the preferred way of using this handler though). Now I get this error:
Odd number of elements in anonymous hash at /home/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Plack/Middleware.pm line 23.
Inspection of Plack::Middleware shows that one of the arrayrefs in the middleware spec should instead be an array, i.e.:
set plack_middlewares => [
[
AccessLog => ( # <-- note change
format => 'combined',
logger => sub { $logfh->print( @_ ) },
), # <-- and here
],
];
However, now the server just simply fails to start, so it's dying later on. Help? :)
karenetheridge
commented
Mar 21, 2012
Ok, I sourcedived some more and found that explicitly setting $ENV{PLACK_ENV} would force the PSGI handler to be used (I'm skeptical that this is the preferred way of using this handler though). Now I get this error: Odd number of elements in anonymous hash at /home/perlbrew/perls/perl-5.14.2/lib/site_perl/5.14.2/Plack/Middleware.pm line 23. Inspection of Plack::Middleware shows that one of the arrayrefs in the middleware spec should instead be an array, i.e.:
However, now the server just simply fails to start, so it's dying later on. Help? :) |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
karenetheridge
Mar 21, 2012
I solved my issue by converting my executable to a psgi and applying the middleware there, then calling Dancer::dance($request) within the $app sub. However, it seems that programmatic application of middlewares should still work within Dancer, so I'm leaving this ticket open.
karenetheridge
commented
Mar 21, 2012
I solved my issue by converting my executable to a psgi and applying the middleware there, then calling Dancer::dance($request) within the $app sub. However, it seems that programmatic application of middlewares should still work within Dancer, so I'm leaving this ticket open. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
xsawyerx
Mar 24, 2012
Owner
@karenetheridge My apologies for having this sit here for a while.
Could you perhaps minimize this to a very specific use case I could play with?
We've had the middlewares API change and we needed to update the docs, but I believe we've already done so. Have you tried other Plack middlewares? Perhaps this specific one has a side-effect by providing a coderef? Doesn't seem likely, I know, but I usually try to do that too just to make sure I'm not missing any side-effects by accident...
I'll take some time today to check this out. FWIW, Pinto++. :)
@karenetheridge My apologies for having this sit here for a while. Could you perhaps minimize this to a very specific use case I could play with? We've had the middlewares API change and we needed to update the docs, but I believe we've already done so. Have you tried other Plack middlewares? Perhaps this specific one has a side-effect by providing a coderef? Doesn't seem likely, I know, but I usually try to do that too just to make sure I'm not missing any side-effects by accident... I'll take some time today to check this out. FWIW, Pinto++. :) |
added a commit
to pjf/Dancer
that referenced
this issue
Nov 20, 2012
added a commit
to pjf/Dancer
that referenced
this issue
Nov 20, 2012
added a commit
that referenced
this issue
Nov 25, 2012
added a commit
to mokko/Dancer
that referenced
this issue
Nov 25, 2012
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
bigpresh
Nov 28, 2012
Owner
I see changes were made to improve middleware docs - is this still an issue now, or have those changes taken care of it?
Also, sorry this issue has sat untouched for so long!
I see changes were made to improve middleware docs - is this still an issue now, or have those changes taken care of it? Also, sorry this issue has sat untouched for so long! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Show comment Hide comment
pjf
Feb 28, 2013
Contributor
Sorry for the super-slow response, AFAIK the documentation now matches uses (which works!), and so this issue can now be closed.
Sorry for the super-slow response, AFAIK the documentation now matches uses (which works!), and so this issue can now be closed. |
@pfenwick Thank you! :) |
karenetheridge commentedMar 21, 2012
I'm trying to programmatically apply middlewares, as described in Dancer::Cookbook:
For example, I'm inserting this code:
...right above the call to Dancer::dance() in https://github.com/karenetheridge/Pinto-Server/blob/master/lib/Pinto/Server.pm. This doesn't seem to work, as hits to the server do not result in entries appearing in access.log.