I like the idea of this new module:
http://search.cpan.org/~phaylon/Catalyst-Controller-Constraints-0.10_01/lib/Catalyst/Controller/Constraints.pm
Conceptually, it helps clean-up and minimize mundane query parameter
validation for web applications.
In a central place you can define basic constraints, such what a digit
looks like, along with a run mode to handle invalid input of this type,
such as returning a page with the message: "Query Could not be understood".
What's left is a little signature on the run mode, so you can still see
that what's going on, but you can get directly to the interesting
business logic, without starting out so many run modes with somewhat
repetitive stanzas of checking the query parameters and possibly
returning an error:
# add two integers, just throws exception on constraint failure
sub add : Local Args(2) Constraints(Integer a, Integer b) {
my ( $self, $c ) = @_;
$c->res->body( $_{a} + $_{b} );
}
It doesn't seem to be an exactly "light" solution, though. It in turn
loads Moose, Class::Delegator, Exception::Class, Hash::Merge and Scalar
Util.
Still, it seems interesting to me to explore doing something like this
with CGI::Application.
Mark
---------------------------------------------------------------------
Web Archive: http://www.mail-archive.com/[email protected]/
http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]