[Dancer-users] redirect path is wrong

Puneet Kishor punk.kish at gmail.com
Tue Jun 5 20:02:12 CEST 2012




On Jun 5, 2012, at 10:58 AM, Nathan Marley <nathan.marley at gmail.com> wrote:

> Have you looked at the forward() method?
> 
> The second argument is a hashref with the params you want to pass along.


That is good advice. I will check out forward(), however, in this case I think I do want a redirect. I am trying to implement an HTTP permanent redirect, so I want the URI to change in the address bar. Which is why I want to pass the entire params hashref to the new URI.


> 
> from 'perldoc Dancer':
> 
>    forward
>        Runs an internal redirect of the current request to another request.
>        This helps you avoid having to redirect the user using HTTP and set
>        another request to your application.
> 
> 
> 
> On Mon, Jun 4, 2012 at 5:22 PM, Mr. Puneet Kishor <punk.kish at gmail.com> wrote:
> 
> On Jun 4, 2012, at 5:04 PM, WK wrote:
> 
> > 2012/6/5 Mr. Puneet Kishor <punk.kish at gmail.com>:
> >
> >> In my code, I have put the following
> >>
> >>        get '/resource.:format' { return redirect '/gmna/resource.:format'; };
> >>        get '/gmna/resource.:format' => {
> >>                ..
> >>        };
> >>
> >> But the above fails. One, the redirect doesn't seem to recognize and carry the .:format through (if I call resource.json, the program complains that '/gmna/resource.:format' wasn't found).
> >
> >
> > AFAIU, redirect needs path or url, it does not work with tokens, you
> > need to give param or variable, like:
> >
> >  get '/resource.:format' { return redirect '/gmna/resource.' .
> > param('format'); };
> >
> >> Second, it doesn't prefix the /app/d/geomaps part to the redirected URI.
> >
> > Some threads back it was asked also. Return can't originate from your
> > prefix, because then is not possible to redirect to non-prefixed
> > paths.   Solution is to write your own wrapper like
> > redirect_with_prefix.
> >
> 
> 
> fantastic... both those suggestions worked well.
> 
> However, the add-on question is that other query params didn't get "redirected" as well. I am guessing I have to "manually" add them to the redirect command just as I am adding the param('format') bit. However, since I don't know the params that might have been sent to the old URI, is there a way to send with the redirect request whatever params are in the query string?
> 
> 
> --
> Puneet Kishor
> _______________________________________________
> Dancer-users mailing list
> Dancer-users at perldancer.org
> http://www.backup-manager.org/cgi-bin/listinfo/dancer-users
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.backup-manager.org/pipermail/dancer-users/attachments/20120605/ab1f507b/attachment.htm>


More information about the Dancer-users mailing list