From 1abaa6418db52bab365517c52579c7d6d2da3c7b Mon Sep 17 00:00:00 2001 From: mdreamfly Date: Mon, 22 Feb 2016 08:02:43 +0800 Subject: [PATCH 1/3] support restify req.body --- lib/wechat.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/wechat.js b/lib/wechat.js index bd253d87..cf6ae70b 100644 --- a/lib/wechat.js +++ b/lib/wechat.js @@ -119,8 +119,9 @@ var load = function (stream, callback) { // support content-type 'text/xml' using 'express-xml-bodyparser', which set raw xml string // to 'req.rawBody'(while latest body-parser no longer set req.rawBody), see // https://github.com/macedigital/express-xml-bodyparser/blob/master/lib/types/xml.js#L79 - if (stream.rawBody) { - callback(null, stream.rawBody); + // support restify req.body + if (stream.rawBody||stream.body) { + callback(null, stream.rawBody||stream.body); return; } From 1b5249116622f78e09cf8a8a77e8fd4f21e30be2 Mon Sep 17 00:00:00 2001 From: mdreamfly Date: Mon, 22 Feb 2016 10:10:18 +0800 Subject: [PATCH 2/3] support restify req.body --- .idea/vcs.xml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 00000000..94a25f7f --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file From 10675d76ddd2c8778ef6e129fc86623b812bd254 Mon Sep 17 00:00:00 2001 From: mdreamfly Date: Mon, 22 Feb 2016 10:44:18 +0800 Subject: [PATCH 3/3] var body = stream.rawBody || stream.body; --- lib/wechat.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/wechat.js b/lib/wechat.js index cf6ae70b..7056bc56 100644 --- a/lib/wechat.js +++ b/lib/wechat.js @@ -120,8 +120,10 @@ var load = function (stream, callback) { // to 'req.rawBody'(while latest body-parser no longer set req.rawBody), see // https://github.com/macedigital/express-xml-bodyparser/blob/master/lib/types/xml.js#L79 // support restify req.body - if (stream.rawBody||stream.body) { - callback(null, stream.rawBody||stream.body); + + var body = stream.rawBody || stream.body; + if (body) { + callback(null, body); return; }