[Catalyst] Usage of $c->uri_for and $c->res->redirect

Dustin Suchter dsuchter at ucla.edu
Wed Mar 26 20:31:36 GMT 2008


Can you directly control the port you redirect to? Part of my 
problem is having consistency between the production and test 
environments, which operate on 80/443 and 3000/3000 respectively.

-d

Ashley wrote:
> There are two approaches which have helped me. Remember the URI object 
> underneath can be your friend.
> 
> 1) Keep things relative.
>    $c->uri_for("/blah")->path
>    $c->uri_for("/blah")->path_query
> 
> 2) Change the scheme yourself.
>    my $uri = $c->uri_for("/blah");
>    $uri->scheme( $my_test ? "http" : "https" );
> 
> -Ashley
> 
> On Mar 26, 2008, at 1:13 PM, Dustin Suchter wrote:
> 
>> Let's say I want to send people back and forth between an HTTP 
>> connection and an HTTPS connection on a server based on some action. 
>> For example, clicking on a "logout" button from within my application 
>> while connected via HTTPS does something like:
>>
>> $c->res->redirect("http://foo.com/");
>>
>> The above seems like a fine solution except it totally disregards the 
>> beauty of uri_for, which I would love to be using for stuff like this. 
>> Without uri_for, problems arise when you do things like test via the 
>> built in Perl webserver (the one running on port 3000 by default) 
>> while on the same webserver as my "production" application.
>>
>> So the real question is, how do I properly refer to my webserver 
>> and/or application root and include port or SSL flags? I guess I'm 
>> looking for something like $0 within uri_for.
>>
>> -d
>>
>> _______________________________________________
>> List: Catalyst at lists.scsys.co.uk
>> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
>> Searchable archive: 
>> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
>> Dev site: http://dev.catalyst.perl.org/
> 
> 
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
> 



More information about the Catalyst mailing list