[dancer-users] Accepting JSON in a POST request

Gabor Szabo gabor at szabgab.com
Mon Aug 24 09:31:32 BST 2015


Hi,

When I send a POST request with JQuery or with a plan HTML form I see

'CONTENT_TYPE' => 'application/x-www-form-urlencoded; charset=UTF-8',

and the data looks like this:

'body' => 'foo=23&bar=19',


If I understand it correctly then this is what Dancer turns into the values
accessible via param()

When I use Angular to send a POST request to the Dancer back-end, by
default it send

'CONTENT_TYPE' => 'application/json;charset=UTF-8',

and the data looks like this:

'body' => '{"foo":23,"bar":19}',

and Dancer2 does not parse this.


Shouldn't Dancer2 look at the content type of the POST request and handle
the data accordingly?
Or is that the job of PSGI? Do I need to tell something to Dancer2 or to
PSGI to do this?

regards
   Gabor
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.preshweb.co.uk/pipermail/dancer-users/attachments/20150824/fb5334c9/attachment.html>


More information about the dancer-users mailing list