[Catalyst] How to de-serialize json?
Bill Moseley
moseley at hank.org
Sun Jan 24 02:47:00 GMT 2010
On Sat, Jan 23, 2010 at 5:39 PM, Hans Dieter Pearcey <
hdp.perl.catalyst.users at weftsoar.net> wrote:
> Excerpts from Bill Moseley's message of Sat Jan 23 19:45:28 -0500 2010:
>
> > With a jpeg I assume the content type would be form-data (that included
> an
> > upload in the form) where the file ends up in $req->uploads, not as a
> > request parameter.
>
> That assumption may hold true for *your* applications, but he didn't say
> anything about a form or even a web browser. It's perfectly reasonable,
> especially in the context of REST APIs, to talk about non-form-based
> request
> bodies. (I've written actions that accepted PUT requests with a
> content-type
> of application/vnd.ms-excel, for example.)
>
But, that's a different content type. I assumed form-data. So, in this
case in my "HTTP::Body deserialization layer" approach, I'd thus add:
$HTTP::Body::Types('application/vnd.ms-excel') =3D 'My::ExcelParser';
which would result in $req->uploads having an upload object for the
spreadsheet. My::ExcelParser would probably be a thin sub-class of
something like My::Upload. Then the same controller would work with both a
web request with an upload field or this REST request and expect to find the
upload object in $req->uploads.
-- =
Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20100123/7f66f=
36d/attachment.htm
More information about the Catalyst
mailing list