Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of LTjake (4001)

Tuesday November 28, 2006
10:04 AM

More on generic controllers

[ #31743 ]

In relation to my last post, a co-worker asked me how i might add a URL like /admin/account/create to the mix. here is what i came up with for a solution:

package MyApp::Controller::Admin::Account;

use strict;
use warnings;

use base 'Catalyst::Controller';

# methods on /admin/account/
sub root     : Chained('/') PathPrefix CaptureArgs(0) { }
sub list     : Chained('root') PathPart('') Args(0) { die "index of accounts" }

# methods on /admin/account/$name
sub create   : Chained('root') PathPart Args(0) { die "create an account" }

# methods on /admin/account/$id/[$name]
sub instance : Chained('root') PathPart('') CaptureArgs(1) { }
sub view     : Chained('instance') PathPart('') Args(0) { die "view account" }
sub update   : Chained('instance') PathPart Args(0) { die "update account" }

1;

I've added in a root midpoint which will allow us to chain any other method off of /admin/account.

(Again, sanity checked by mst)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.