[Catalyst] Input filtering -- XMLRPC dispatch type
Bill Moseley
moseley at hank.org
Thu Mar 27 01:22:39 GMT 2008
I'm looking for some design advice:
I'm exposing many controllers to XMLRPC requests. I have an XMLRPC
dispatch type so for many of the controllers it's just a matter of
adding an XMLRPC( 'some.api.method' ) sub attribute to existing actions.
In many cases the arguments passed in the XMLRPC need to be mapped to
the parameters that the controller needs. Therefore, I need to call
some code before the action is run to do this mapping.
This is basically action-specific input filtering.
My question is this:
Where do these action and XMLRPC specific methods go?
One option would be in the controller itself.
package MyApp::User;
use base 'Catalyst::Controller';
# List all users
sub list_all : Local : XMLRPC( 'user.list_all' ) {}
# Method that is called to map parameters
# before list_all() is called.
sub xmlrpc_begin_list_all {}
But, then I'm cluttering up the controllers. Plus, there may be more
than just XMLRPC so I don't want to have <api_type>_begin_<action>
methods for each type. Gets messy.
Another approach would be a separate namespace for the mapping
methods:
package MyApp::Filter::XMLRPC::User;
# map parameters for the MyApp::User::list_all action
sub list_all {}
How would you do this?
--
Bill Moseley
moseley at hank.org
More information about the Catalyst
mailing list