Perl REST flow layout

apache, mod-perl, model-view-controller, perl, rest

Solution

You might be interested in the excellent CGI::Application framework from CPAN. Despite its name, it works both under normal CGI and mod_perl. It's designed to make the task of setting up web-app dispatch tables very simple. Throw in CGI::Application::Dispatch and you get nice REST-like URLs.

Problem

I'm using Apache and Perl (modperl), with Handlers to handle requests. I'm new to this, and I'm not quite sure how to lay things out in a sensible way. Right now I have the following: ``` package MyClass::Handler; use warnings; use strict; # includes our %action = ( 'a' => \&a, # And more ); sub handler { my $a = shift; my $r = Apache2::Request->new($a); # Do things return Apache2::Const::OK(); } ``` Should I have a different file for each "space"? Using stackoverflow as a template, do I need a User.pm for all the User management? A Story.pm for stories?

Original source