Skip to content

Commit

Permalink
fix(package): fix response content type
Browse files Browse the repository at this point in the history
  • Loading branch information
ToQoz committed Dec 19, 2015
1 parent e6ddcec commit 41451b0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ module.exports = function(app, routes) {
} else {
try {
statusCode = route.statusCode;
contentType = req.accepts(Object.keys(route.responseTemplates)).contentType || "application/json";
if (Object.keys(route.responseTemplates).length > 0) {
contentType = req.accepts(Object.keys(route.responseTemplates)) || "application/json";
} else {
contentType = "application/json";
}
responseTemplate = route.responseTemplates[contentType.toLowerCase()] || "$input.json('$')";
} catch(error) {
this.done(error, null);
Expand All @@ -60,8 +64,8 @@ module.exports = function(app, routes) {
payload: JSON.stringify(obj)
});

res.setHeader("Content-Type", contentType);
res
.set('content-type', contentType)
.status(statusCode)
.send(responseBody);
},
Expand Down

0 comments on commit 41451b0

Please sign in to comment.