> Any suggestions on how to do this?  I'm toying with a large switch statement 
> in the root controller and visiting the appropriate controller/action based 
> on the parameter.  Is this right?  Does Catalyst provide a way to accomplish 
> this either easier or cleaner?

Hi Bill,

Rather than a big mess of a switch statement, I would be inclined to construct 
a hash that contains the rules for the mapping of the short-codes to the 
appropriate Controller/action, i.e.

my $codes = {
        'tms' => [ 'Controller1', 'action1' ],
        'tve' => [ 'Controler1', 'action2' ],
        'prn' => [ 'ControllerN', 'actionN' ],
};

then the control flow is more or less abstracted into a simple hash of rules:

if($args[0] =~ /^(\w{3})(\w{13})$/){ # separate media type from key
        my ($code, $key) = ($1, $2);
        if(my $ca = $codes->{$code}){
                $c->forward("MyApp::Controller::".$ca->[0], $ca->[1], [ $key, 
@args ]);
        }
        else {
                ...
        }
}

To be honest, I think this is the sort of use for which the 'Regex' action type 
shines, but I believe it's being deprecated.

cheers
RET
_______________________________________________________________
If the programmers like each other, they play a game called "pair programming".
And if not, then the game is called "peer review".
- Anna Nachesa (@ashalynd)

Richard Thomas




_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to