This is in response to LTJake's examples of setting up a generic base controller with Catalyst
Here's what the same thing would look like using CGI::Application.
# Normally one CGI::App dispatch table is used for
# an entire application, not just one module.
use CGI::Application::Dispatch;
CGI::Application::Dispatch->dispatch(
prefix => 'MyApp::Controller::Admin::Account',
table => [
'admin/account/:id/:rm' => {},
'admin/account/:rm' => {},
'' => {},
]
);
package MyApp::Controller::Admin::Account;
use base 'CGI::Application';
use CGI::Application::Plugin::AutoRunmode;
use strict;
use warnings;
# default for /admin/account/
sub list : StartRunmode { die "index of accounts" }
# methods on /admin/account/$rm
sub create : Runmode { die "create an account" }
# methods on /admin/account/$id/[$rm]
sub instance : Runmode { # do something with $self->param('id') }
sub view : Runmode { die "view account" }
sub update : Runmode { die "update account" }
1;
The amount of code needed in both cases is comparable, but there are two
important philosophical differences here: