Hello, Sometimes I need to redirect to another page after testing things, and I want to leave the route ASAP, so I do something like: get '/test' => sub { if(params->{whatever}) { redirect '/'; return; } "Other stuff, blah"; }; get '/' => sub { template 'index'; }; I've switched to the dev branch, and that return after the redirect results in following error: Use of uninitialized value $line in length at ../local/HTTP/Server/Simple/PSGI.pm line 137. My question is: am I doing it right using return to leave the handler? Cheers, Juanjo -- jjm's home: http://www.usebox.net/jjm/ blackshell: http://blackshell.usebox.net/ ramble on: http://rambleon.usebox.net/
Eh, it's because of the empty body. redirect '/'; return 'Redirecting...'; It's OK. Cheers, Juanjo El vie, 09-04-2010 a las 15:04 +0100, Juan J. Martínez escribió:
Hello,
Sometimes I need to redirect to another page after testing things, and I want to leave the route ASAP, so I do something like:
get '/test' => sub { if(params->{whatever}) { redirect '/'; return; }
"Other stuff, blah"; };
get '/' => sub { template 'index'; };
I've switched to the dev branch, and that return after the redirect results in following error:
Use of uninitialized value $line in length at ../local/HTTP/Server/Simple/PSGI.pm line 137.
My question is: am I doing it right using return to leave the handler?
Cheers,
Juanjo
-- jjm's home: http://www.usebox.net/jjm/ blackshell: http://blackshell.usebox.net/ ramble on: http://rambleon.usebox.net/
Hello Juan, Le vendredi 09 avril 2010 à 15:09 +0100, Juan J. Martínez a écrit :
Eh, it's because of the empty body.
redirect '/'; return 'Redirecting...';
Well, actually you found a bug ;) I've reproduce this bug in a new test script: http://github.com/sukria/Dancer/blob/devel/t/03_route_handler/11_redirect_no... And fixed the bug in the devel branch. http://github.com/sukria/Dancer/commit/de69197684606b5a867399fdc33c48b5ddc71... A route can now return a void response (return;) and the content won't be undefined. Thanks for the report. Regards, -- Alexis Sukrieh
participants (2)
-
Alexis Sukrieh -
Juan J. Martínez