[Dancer-users] path_info is not set up
Иван Бессарабов
ivan at bessarabov.ru
Wed Jan 26 07:10:57 CET 2011
I'm running dancer app with plackup:
DANCER_ENVIRONMENT='development' plackup -s FCGI --port 3001 myapp.pl
I'm using nginx as a web sever. Here is part of its config:
server {
listen 3000;
location / {
fastcgi_pass 127.0.0.1:3001;
include /etc/nginx/fastcgi_params;
}
}
With this configuration I can access the main page of my app, but only
it. In development.log I always get:
[27975] core @0.000759> request: GET / from 1.1.1.1 in
/usr/share/perl5/Dancer/Handler.pm l. 49
To find out why this is so I've added 3 lines to before sub in my app:
debug request->{path};
debug request->path_info();
debug request->to_string();
After restarting plackup, I access "/":
[28457] core @0.000769> request: GET / from 1.1.1.1 in
/usr/share/perl5/Dancer/Handler.pm l. 49
...
[28457] debug @0.035033> [hit #1]/ in /var/www/myapp/lib/myapp.pm l. 41
[28457] debug @0.035033> [hit #1]/ in /var/www/myapp/lib/myapp.pm l. 42
[28457] debug @0.038886> [hit #1][#1] GET / in /var/www/myapp/lib/myapp.pm l. 43
And here is the log when I try to access "/abc" (in the browser I
still see the main page):
[28457] core @0.000246> request: GET / from 1.1.1.1 in
/usr/share/perl5/Dancer/Handler.pm l. 49
...
[28457] debug @0.016833> [hit #2]/abc in /var/www/myapp/lib/myapp.pm l. 41
[28457] debug @0.018028> [hit #2]/ in /var/www/myapp/lib/myapp.pm l. 42
[28457] debug @0.018363> [hit #2][#2] GET /abc in
/var/www/myapp/lib/myapp.pm l. 43
I looked through the dancer code and found out that is be because
$self->{env}->{'PATH_INFO'} is empty line in sub _build_path_info in
the file Request.pm
A dirty workaroud is to place "request->path_info(request->{path});"
in before sub in the app. But this is bad because redirects do not
work.
So. My question is: how can I fix populating PATH_INFO in my app,
running with plackup and nginx.
More information about the Dancer-users
mailing list