Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Manual merge of branch digineo:square_brackets, Issue #128

  • Loading branch information...
commit 358943f3301945d13a19d561a2f9f34be8b6da2a 1 parent ab7017c
Alexandra Adkins authored
Showing with 30 additions and 27 deletions.
  1. +24 −23 app.js
  2. +6 −4 views/api.jade
View
47 app.js
@@ -519,7 +519,9 @@ function processRequest(req, res, next) {
var reqQuery = req.body,
customHeaders = {},
- params = reqQuery.params || {},
+ params = {},
+ keys = reqQuery.keys || {},
+ values = reqQuery.values || {},
locations = reqQuery.locations || {},
methodURL = reqQuery.methodUri,
httpMethod = reqQuery.httpMethod,
@@ -530,28 +532,27 @@ function processRequest(req, res, next) {
key = req.sessionID + ':' + apiName,
implicitAccessToken = reqQuery.accessToken;
- for (var param in params) {
- if (params.hasOwnProperty(param)) {
- if (params[param] !== '') {
- if (locations[param] == 'header') {
- // Extract custom headers from the params
- customHeaders[param] = params[param];
- delete params[param];
- } else {
- // Replace placeholders in the methodURL with matching params
- // URL params are prepended with ":"
- var regx = new RegExp(':' + param);
-
- // If the param is actually a part of the URL, put it in the URL and remove the param
- if (!!regx.test(methodURL)) {
- methodURL = methodURL.replace(regx, encodeURIComponent(params[param]));
- delete params[param]
- }
- }
- } else {
- delete params[param]; // Delete blank params
- }
- }
+ for( var i in keys )
+ {
+ var k = keys[i];
+ var v = values[i];
+ if (v !== '')
+ {
+ // Set custom headers from the params
+ if (locations[i] == 'header' ) {
+ customHeaders[k] = v;
+ } else {
+ // URL params are prepended with ":"
+ var regx = new RegExp(':' + k);
+
+ // If the param is actually a part of the URL, put it in the URL
+ if (!!regx.test(methodURL)) {
+ methodURL = methodURL.replace(regx, v);
+ } else {
+ params[k] = v;
+ }
+ }
+ }
}
var baseHostInfo = apiConfig.baseURL.split(':');
View
10 views/api.jade
@@ -110,6 +110,8 @@ block content
- each parameter in method.parameters
- paramCount++
div(id='param' + paramCount)
+ input(type='hidden', name='keys['+paramCount+']', value=parameter.Name)
+ - input_name = 'values['+paramCount+']'
- if (parameter.Required =='Y')
- var required =true
- var className ='required'
@@ -119,8 +121,9 @@ block content
tr(class=className)
td.name!=parameter.Name
td.parameter
+ input(type='hidden', name='locations['+paramCount+']', value=parameter.Location || 'query')
- if (parameter.Type =='enumerated')
- select(name='params[' + parameter.Name + ']', placeholder=className)
+ select(name=input_name, placeholder=className)
- if (parameter.Default =='')
option(value='')
- each choice in parameter.EnumeratedList
@@ -129,7 +132,7 @@ block content
- else
option(value=choice) #{choice}
- else if (parameter.Type =='boolean')
- select(name='params[' + parameter.Name + ']', placeholder=className)
+ select(name=input_name, placeholder=className)
- if (parameter.Default =='')
option(value='')
- each choice in [apiInfo.booleanTrueVal,apiInfo.booleanFalseVal]
@@ -146,8 +149,7 @@ block content
input(type='password', name='params[' + parameter.Name + ']', value=parameter.Default)
input(type='hidden', name='locations['+parameter.Name+']', value=parameter.Location || 'query')
- else
- input(name='params[' + parameter.Name + ']', value=parameter.Default, placeholder=className)
- input(type='hidden', name='locations['+parameter.Name+']', value=parameter.Location || 'query')
+ input(name=input_name, value=parameter.Default, placeholder=className)
td.type!=parameter.Type
td.location
p!=parameter.Location || 'query'
Please sign in to comment.
Something went wrong with that request. Please try again.