[Catalyst] website member urls

Tomas Doran bobtfish at bobtfish.net
Thu Apr 30 14:04:44 GMT 2009


J. Shirley wrote:
> If you did want to do something in Catalyst, you could create a plugin 
> that runs after prepare_path and modifies $c->request->path accordingly 
> (match off $c->req->base domain)... it'd be an interesting plugin, 
> that's for sure.  I'm sure some of the deeper Catalyst hackers can think 
> of alternative, and perhaps simpler, ways to do it.

package MyApp::RequestRole::PrependHostName;
use Moose::Role;

around path => sub {
     my ($orig, $self, @path) = @_;

     return $self->$orig() if ! @path;

     $self->$orig($self->hostname, @path));
};

package MyApp;
use Moose;
use Catalyst;
use Catalyst::App::RoleApplicator;

__PACKAGE__->apply_request_class_roles(
       qw/MyApp::RequestRole::PrependHostName/
);

I think would do what you want (untested).

I am unsure if this is a sane approach however, but that has already 
been covered elsewhere in the thread. :_)

Cheers
t0m



More information about the Catalyst mailing list