[Dancer-users] working with HTTP env vars

P Kishor punk.kish at gmail.com
Thu Aug 19 21:27:42 CEST 2010


On Thu, Aug 19, 2010 at 12:41 PM, Olaf Alders <olaf at wundersolutions.com> wrote:
>
> 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,
>

wow! That Plack advent calendar is brilliant. I am learning a lot from
it, however, I am not sure it helps me. Since I am already using
Dancer, I am "supposed" to be shielded from dealing with Plack
directly, no? In other words, (from the quote above), Dancer should
give me access to PATH_INFO and SCRIPT_NAME, etc. Which is precisely
what I want.





-- 
Puneet Kishor http://www.punkish.org
Carbon Model http://carbonmodel.org
Charter Member, Open Source Geospatial Foundation http://www.osgeo.org
Science Commons Fellow, http://sciencecommons.org/about/whoweare/kishor
Nelson Institute, UW-Madison http://www.nelson.wisc.edu
-----------------------------------------------------------------------
Assertions are politics; backing up assertions with evidence is science
=======================================================================


More information about the Dancer-users mailing list