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

Byron Young Byron.Young at riverbed.com
Wed Mar 26 20:38:33 GMT 2008


> -----Original Message-----
> From: Dustin Suchter [mailto:dsuchter at ucla.edu]
> Sent: Wednesday, March 26, 2008 1:13 PM
> To: The elegant MVC web framework
> Subject: [Catalyst] Usage of $c->uri_for and $c->res->redirect
>
> 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

Hey Dustin,

There's actually a neat plugin for doing this called Catalyst::Plugin::RequireSSL.  You just include it in your plugins and then call $c->require_ssl() at the top of any actions you want to use SSL for.  It will disable itself automatically on the test server, too.

Cheers,
Byron



More information about the Catalyst mailing list