Skip to content

Commit

Permalink
Fixed options method validation and Threadneedle request
Browse files Browse the repository at this point in the history
  • Loading branch information
johnbastian-trayio committed Jan 21, 2020
1 parent 5daacce commit 013bfdb
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/addMethod/addMethodREST.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ module.exports = function (methodName, config, afterHeadersFunction) {
case 'head':
needle[method](request.url, request.options, handleResponse);
break;
case 'options':
needle.request('options', request.url, request.options, handleResponse);
break;
default:
needle[method](request.url, request.data, request.options, handleResponse);
}
Expand Down
2 changes: 1 addition & 1 deletion lib/addMethod/validateRESTInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ module.exports = function (methodName, config) {
if (_.isString(method)) {
if (!identifySimpleMustache(method)) {
method = method.toLowerCase();
const allowedMethods = [ 'get', 'put', 'post', 'delete', 'head', 'patch' ];
const allowedMethods = [ 'get', 'put', 'post', 'delete', 'head', 'patch', 'options' ];
if (allowedMethods.indexOf(method) === -1) {
throw new Error('The `method` "'+method+'" is not a valid method. Allowed methods are: '+allowedMethods.join(', '));
}
Expand Down
2 changes: 1 addition & 1 deletion tests/addMethodREST_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('#addMethodREST', function () {
method: 'chris'
});
} catch (err) {
assert.strictEqual(err.message, 'The `method` "chris" is not a valid method. Allowed methods are: get, put, post, delete, head, patch');
assert.strictEqual(err.message, 'The `method` "chris" is not a valid method. Allowed methods are: get, put, post, delete, head, patch, options');
caught++;
}
assert.strictEqual(caught, 1);
Expand Down

0 comments on commit 013bfdb

Please sign in to comment.