Redirects // Re: [Catalyst] Re: forwarding to chained actions

Bill Moseley moseley at hank.org
Fri Apr 27 19:49:18 GMT 2007


On Fri, Apr 27, 2007 at 02:03:23PM +0100, Simon Wilcox wrote:
> So, what do people do - do you send 303/307's "correctly" or just default
> to 302 behaviour ?

I use something like this, although you might want to customize:

sub post_redirect {
    my ( $c, $location ) = @_;
    my ($version) = $c->request->protocol =~ m/(\d+\.\d+)/;

    # Make location absolute
    $location = $c->uri_for( $location )
        unless $location =~ /http/;

    $c->res->redirect( $location, ( $version && $version > 1.0 ? 303 : 302 ));
}

One change would be to pass a comment that gets stuffed into the
session (flash).



-- 
Bill Moseley
moseley at hank.org




More information about the Catalyst mailing list