Permalink
Browse files

added support for application/json payload

  • Loading branch information...
1 parent e70a81a commit 8122bd3fcd1f562a915c628975c782752d25ec6b @DracoBlue DracoBlue committed Sep 18, 2011
Showing with 10 additions and 1 deletion.
  1. +1 −0 CHANGELOG.md
  2. +9 −1 core/server/ServerApplication.js
View
@@ -9,6 +9,7 @@ Spludo is copyright 2009-2011 by DracoBlue <http://dracoblue.net>
## 1.1.0-dev
+* added support for application/json paylod
* generate *ByIds method for services
* added ApiServiceController to register a service as REST service
* context.request now holds the current req instance
@@ -75,7 +75,15 @@ ServerApplication.prototype.run = function() {
/*
* Ok, we need to parse that!
*/
- extend(true, context.params, querystring.parse(body));
+ try {
+ if (req.headers['content-type'] && req.headers['content-type'].match(/^application\/json.*/)) {
+ extend(true, context.params, JSON.parse(body));
+ } else {
+ extend(true, context.params, querystring.parse(body));
+ }
+ } catch (error) {
+
+ }
}
ContextToolkit.applyRequestHeaders(context, req.headers);

0 comments on commit 8122bd3

Please sign in to comment.