<div dir="ltr">







<p class=""><span class="">Hi,</span></p>
<p class=""><span class=""></span><br></p>
<p class=""><span class=""><a href="http://search.cpan.org/~yanick/Dancer-1.3134/lib/Dancer.pm#redirect">http://search.cpan.org/~yanick/Dancer-1.3134/lib/Dancer.pm#redirect</a></span></p>
<p class=""><span class="">"Generates an HTTP redirect (302)."</span></p>
<p class=""><span class="">I believe the RFC2616 doesn’t forbid message-body on 300-ish routes so that’s probably why:</span></p>
<p class=""><span class="">"</span><span class="">Redirection is deferred until after the current route or filter has been processed."</span></p>
<p class=""><span class=""></span><br></p>
<p class=""><span class="">So, if you:</span></p>
<p class=""><span class=""></span><br></p>
<p class=""><span class="">redirect ‘/someroute’ if $something;</span></p>
<p class=""><span class="">return $content;</span></p>
<p class=""><span class="">"means": issue a http 302 to ‘/someroute’ w/ $content as message body. </span></p>
<p class=""><span class=""><br></span></p><p class=""><span class="">and,</span></p><p class=""><span class=""><br></span></p>
<p class=""><span class="">return redirect '‘/someroute’ if $something</span></p>
<p class=""><span class="">“means": issue a http 302 to ‘/someroute’ and w/o message-body</span></p><p class=""><span class=""><br></span></p>
<p class=""><span class="">cheers,</span></p>
<p class=""><span class="">Tiago</span></p></div><div class="gmail_extra"><br><div class="gmail_quote">On 18 March 2015 at 07:08, Pedro Melo <span dir="ltr"><<a href="mailto:melo@simplicidade.org" target="_blank">melo@simplicidade.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Writing this from memory, but redirect doesn't abort the current request processing, so you need to return redirect on all places.<br>
<br>
Sent from my iPhone<br>
<div><div class="h5"><br>
> On 17/03/2015, at 23:46, David H <<a href="mailto:untg99@gmail.com">untg99@gmail.com</a>> wrote:<br>
><br>
> So I had this question and I couldn't find any answer, since the two options were giving me confusion. I wanted t pass control off to another route if a certain action happened.<br>
><br>
> I had this in a route:<br>
> if ($actionHappened) {<br>
>    redirect '/CheckOffOrderItem/';<br>
> }<br>
><br>
> and it was working fine, it would pass control off to that route and then any return would go to the page and return what I wanted.<br>
><br>
> I then went to add another line for something else below this one<br>
> if ($theOtherThingHappened) {<br>
>  redirect '/CheckOffProduct/'<br>
> }<br>
><br>
> and it worked, about twice, then stopped working and wouldn't process the redirect, it would get to the condition and go through but just skip processing the route and continue with the existing route, so I read somewhere that "return redirect" should be used and not "redirect" when redirecting.<br>
><br>
> Is this true? and why?<br>
> My top one is still working and hasn't stopped but I want to know what the logic behind these two are. When I changed the second one to 'return redirect' it started working again.<br>
><br>
> Thanks,<br>
><br>
> David Hancock<br>
</div></div>> _______________________________________________<br>
> dancer-users mailing list<br>
> <a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
> <a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
_______________________________________________<br>
dancer-users mailing list<br>
<a href="mailto:dancer-users@dancer.pm">dancer-users@dancer.pm</a><br>
<a href="http://lists.preshweb.co.uk/mailman/listinfo/dancer-users" target="_blank">http://lists.preshweb.co.uk/mailman/listinfo/dancer-users</a><br>
</blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">Tiago Quintela</div>
</div>