[Dancer-users] working with HTTP env vars
Olaf Alders
olaf at wundersolutions.com
Fri Aug 20 02:57:25 CEST 2010
On 2010-08-19, at 8:20 PM, P Kishor wrote:
> On Thu, Aug 19, 2010 at 5:09 PM, Olaf Alders <olaf at wundersolutions.com> wrote:
>> On 2010-08-19, at 3:27 PM, P Kishor wrote:
>>
>>>>> 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.
>>
>>
>> Could you post a dump of your request->env ?
>
>
> this may sound very dumb, but I frankly don't know how to dump a data
> structure. How do I dump the entire request->env()?
One simple way would be to add the following to your Dancer app:
use Data::Dump qw( dump );
get '/env' => sub {
return '<pre>' . dump( \%ENV ) . '<hr>' . dump( request->env ) . '</pre>';
};
Then, go to /env in your app and copy/paste the output.
You'll find that %ENV != request->env, but they probably both (hopefully) have the info you might need.
--
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