[Dancer-users] working with HTTP env vars

P Kishor punk.kish at gmail.com
Thu Aug 19 15:18:14 CEST 2010


Hi,

Per the docs for 1.1805, I can work with the env vars as follows --

    in my App.pm
    ------------
    my $env = request->env();
    template <tmpl>, {
        var1 => $env->{var1},
        var2 => $env->{var2}
        .. and so on ..
    }

    in my template
    --------------
    var1: [% var1 %]<br />
    var2: [% var2 %]<br />
    .. and so on ..

The above is not working for me as I am trying to use basic Apache env
vars such as REQUEST_URI, SCRIPT_FILENAME, etc.

A little background, since someone might be able to suggest a
different way of accomplishing what I am trying to do --

My web site is at http://mywebsite.org/. In the VirtualHost definition
of mywebsite.org, I have the following

    ProxyPass /app/one http://one.org/
    ProxyPassReverse /app/one http://one.org/

Of course, http://one.org/ is a Dancer application. So, when the users
go to http://mywebsite.org/ they see the regular, static web site.
However, when they go to http://mywebsite.org/app/one/ they see my
Dancer web site. In order to get the correct paths to the CSS and
images and other assets for one.org, I need that '/app/one' bit from
the request uri. That way I can do the following in my template

    <link rel="stylesheet" href="[% uri %]/css/grid.css" />

The reason I can't hard code the above is because there are more than
one applications, and, of course, I want to be able to access the
application directly from http://one.org/ as well.

Suggestions on how I can grab the requested uri?


-- 
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