Skip to content

Commit

Permalink
Added options parameter to callback so that you can set the content t…
Browse files Browse the repository at this point in the history
…ype header (e.g. for non-json returns)
  • Loading branch information
Daryl Rowland authored and Daryl Rowland committed Apr 6, 2017
1 parent 9bb9025 commit d081a46
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,15 @@ var handleMethod = function(methodDefinition, req, res) {
authUser: authUser
};

routeMap[path][method][req.method.toLowerCase()](req, checkedParams.parameters, environment, function(err, result, redirect) {
routeMap[path][method][req.method.toLowerCase()](req, checkedParams.parameters, environment, function(err, result, redirect, options) {
if (options) {
if (options.contentType) {
res.setHeader(options.contentType);
res.send(result);
return;
}
}

if (redirect) {
res.redirect(redirect);
return;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cheese-toastie",
"version": "0.2.11",
"version": "0.2.12",
"description": "NodeJS API Builder",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit d081a46

Please sign in to comment.