[Catalyst] Force https in generated URIs

Larry Leszczynski larryl at emailplus.org
Thu Aug 4 15:57:40 GMT 2011


Hi Tobias -

> Therefore I need to force all generated URIs to be https.

If generated URIs means those coming from $c->uri_for() and friends, you
should be able the modify the URI scheme in $c->request->base, which
gets used by uri_for().

Not tested but try something like the following.

HTH,
Larry

Side question:  Is namespace::autoclean needed any more?

==============================================

package MyApp;

use Moose;

use namespace::autoclean;

BEGIN { extends 'AL::Catalyst::Base' }

with 'MyApp::Roles::Catalyst::IsOnlyHTTPS';

use Catalyst (...);

==============================================

package MyApp::Roles::Catalyst::IsOnlyHTTPS;

use Moose::Role;

use namespace::autoclean;

after 'prepare_path' => sub {

    my $c = shift;

    $c->request->base->scheme('https');

    # Might be necessary to keep request
    # uri in sync with request base?
    # Not sure...
    #
    #$c->request->uri->scheme('https');

    return;
};

1;

==============================================



More information about the Catalyst mailing list