[Dancer-users] redirect path is wrong

Mr. Puneet Kishor punk.kish at gmail.com
Tue Jun 5 00:22:33 CEST 2012


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


More information about the Dancer-users mailing list