[Catalyst] Mapping parameters for web services

Matt S Trout dbix-class at trout.me.uk
Tue Oct 23 21:33:13 GMT 2007


On Mon, Oct 22, 2007 at 03:20:09PM -0700, Bill Moseley wrote:
> I'm looking for suggestions how to best map XMLRPC request parameters into
> the params and arguments that my existing (web) controllers are
> expecting.
> 
> 
> I have a number of controllers that I'd like to expose for web
> services.  The C::P::Server::XMLRPC plugin makes this easy since one
> can add :XMLRPC to any existing controller to expose it.
> 
> My controllers tend to be thin -- that is they don't fetch every bit
> of data that the View might display.  Some of that work is left to the
> templates.  So, for XMLRPC I also have a separate View that prepares
> any data needed for the response.  This view is called instead for
> XMLRPC requests.
> 
> Frankly, feels a bit dirty but I'm doing basically:
> 
>     sub process {
>         my ( $self, $c ) = @_;
>         my $method = $c->action->reverse;
>         $method =~ s[/][_]g;
>         $self->$method( $c ) if $self->can( $method );
>     }
> 
> So, I can add a method to this view for any controller that needs
> extra help preparing the XMLRPC response.
> 
> So, on to my question:
> 
> The parameters and arguments that come in on web requests are
> different than they come in for XMLRPC  requests -- so I need to "map"
> the arguments from the XMLRPC request into the arguments and
> parameters as the existing controllers expect.

I'm not sure I understand; the controller should really just be doing stuff
that's specific to the app UI, so surely you should be mapping both your
existing controllers' input params and te XMLRPC params onto calls to the
same model?

-- 
      Matt S Trout       Need help with your Catalyst or DBIx::Class project?
   Technical Director                    http://www.shadowcat.co.uk/catalyst/
 Shadowcat Systems Ltd.  Want a managed development or deployment platform?
http://chainsawblues.vox.com/            http://www.shadowcat.co.uk/servers/



More information about the Catalyst mailing list