[Dancer-users] working with HTTP env vars

Olaf Alders olaf at wundersolutions.com
Thu Aug 19 19:41:29 CEST 2010


On 2010-08-19, at 10:32 AM, P Kishor wrote:

> On Thu, Aug 19, 2010 at 9:21 AM, Olaf Alders <olaf at wundersolutions.com> wrote:
>> 
>> On 2010-08-19, at 9:18 AM, P Kishor wrote:
>> 
>>> Suggestions on how I can grab the requested uri?
>> 
>> 
>> Have you tried request->path ?
> 
> I had not, but I just did, and that kinda worked, but not really. Let
> me explain.
> 
> As I explained in my original post, I am using a proxy to access the
> Dancer app. In my Apache conf file, I have the following
> 
>   ProxyPass /app/one http://one.org/
>   ProxyPassReverse /app/one http://one.org/
> 
> 
> So, when the address in the browser URL bar is
> http://mywebsite/app/one, the Dancer app is actually getting
> http://one.org/
> 
> In other words, when the user requests http://mywebsite/app/one,
> Dancer's request->path() is simply '/' instead of '/app/one'
> 
> I am hoping to be able to use other Apache variables to grab this, but
> request->env() doesn't seem to be working. Could it be that
> request->env() grabs CGI env variables, and since I am using
> Plack::Handler::Apache2, it is not really CGI that I am using.
> 
> Any other suggestions?

As far as your setup goes, you may want to at least consider something like this:

http://advent.plackperl.org/2009/12/day-12-maps-multiple-apps-with-mount-and-urlmap.html

"The environment variables such as PATH_INFO and SCRIPT_NAME are automatically adjusted so it just works like when your application is mounted using Apache's mod_alias or CGI scripts. Your application framework should always use PATH_INFO to dispatch requests, and concatenate with SCRIPT_NAME to build links."

This should get you pretty much to the same place, but with the added advantage of being able to use Plack's debug panels etc. 

Hope this helps,

Olaf
--
Olaf Alders
olaf at wundersolutions.com

http://www.wundersolutions.com
http://twitter.com/wundercounter

866 503 2204 (Toll free - North America)
416 944 8306 (direct)



More information about the Dancer-users mailing list