Friday, May 13, 2011

Using Dancer's Request HTTP Env shortcuts

As I was working on a small application that allowed editing of pages, I really wanted to grab the referring page to redirect after the page was updated or the edit session was cancelled by the user.

It wasn't very clear to me how to grab the referer from Dancer's POD documentation on Dancer::Request.

Basically I could grab it either of 2 ways.
  1. request->referer - nice. This applies to other env options as well forwarded_for_address which pulls in X_FORWARDED_FOR
  2. request->env->{HTTP_REFERER} - feels more lower level.
I read the documentation as request->env->{referer} which is not correct at all.

In the end it is much easier and I think prettier than the several options I tried :)

__END__

No comments:

Post a Comment