Skip to content
Browse files

Improve parameter handling

  • Loading branch information...
1 parent e4f6107 commit b56d0da82542577796582186ad4e4b4a3edd8529 @DukeyToo DukeyToo committed
Showing with 8 additions and 3 deletions.
  1. +5 −0 lib/server.js
  2. +3 −3 test/params.js
View
5 lib/server.js
@@ -227,6 +227,11 @@ function parseCommand(apiConfig, commandSpec, req) {
config.options = config.options || {};
var options = commandSpec.options;
if (options) {
+ var optionsAsSingleParam = req.param('options')
+ if (optionsAsSingleParam) {
+ cfg.merge(config.options, optionsAsSingleParam)
+ }
+
for (var i=0;i<commandSpec.options.length;i++) {
var option = commandSpec.options[i];
var data, name;
View
6 test/params.js
@@ -68,14 +68,14 @@ describe('Passing of parameters', function() {
})
it('should accept config in the body of a POST as single config param', function(done) {
- var config = {param1: "param1value", param2: "param2value"};
+ var config = {param1: "param1value", param2: "param2value", options: {'option1': 'bar'} };
request({method: 'POST', url: 'http://localhost:3001/api/test/multipleParamsPosted', json: config}, function (error, res, body) {
res.statusCode.should.equal(200);
var result = res.body;
result.should.have.property('param1', 'param1value');
result.should.have.property('param2', 'param2value');
- result.options.should.have.property('option1', 'bla');
+ result.options.should.have.property('option1', 'bar');
done();
})
@@ -94,7 +94,7 @@ describe('Passing of parameters', function() {
})
after(function() {
- var config = {command: 'stop' };
+ var config = {command: 'stop', options: {webworker: false} };
testapi.server(config, function() {
//should stop the server
})

0 comments on commit b56d0da

Please sign in to comment.
Something went wrong with that request. Please try again.