A function that returns the middleware for a given method `getArgs` is a function that should return additional leading service arguments
426038
function getHandler (method, getArgs, trans, domain = 'feathers') {
  return function (req, res, next) {
    res.setHeader('Allow', Object.values(allowedMethods).join(','));

    let params = Object.assign({}, req.params || {});
    delete params.service;
    delete params.id;
    delete params.subresources;
    delete params[0];

    req.feathers = { provider: 'rest' };
    // Grab the service parameters. Use req.feathers and set the query to req.query

    let query = req.query || {};
    let headers = fp.dissoc('cookie', req.headers || {});
    let cookies = req.cookies || {};

    params = Object.assign({ query, headers }, params, req.feathers);

    // Transfer the received file
    if (req.file) {
      params.file = req.file;
    }

    // method override
    if ((method === 'update' || method === 'patch')
      && params.query.$method 
      && params.query.$method.toLowerCase() === 'patch') {
      method = 'patch'
      delete params.query.$method
    }

    // Run the getArgs callback, if available, for additional parameters
    const [service, ...args] = getArgs(req, res, next);

    debug(`REST handler calling service \'${service}\'`, {
      cmd: method,
      path: req.path,
      //args: args,
      //params: params,
      //feathers: req.feathers
    });

    // The service success callback which sets res.data or calls next() with the error
    const callback = function (err, data) {
      debug(`${service}.${method} response:`, err || {
        status: data && data.status,
        size: data && JSON.stringify(data).length
      });
      if (err) return next(err.cause || err);

      res.data = data;

      if (!data) {
        debug(`No content returned for '${req.url}'`);
        res.status(statusCodes.noContent);
      } else if (method === 'create') {
        res.status(statusCodes.created);
      }

      return next();
    };

    trans.act({
      topic: `${domain}.${service}`,
      cmd: method,
      path: req.path,
      args: args,
      params: params,
      feathers: req.feathers
    }, callback);
  };
}
301459
function callApi (method) {
  return function (req, res) {
    var apiAction = api[method](req.guid, req.options)
    handleResponse(apiAction, res)
  }
}
1104493
function splitArgsIntoOptionsAndCallback (args) {
  let params;
  let options;
  let cb;
  if (args.length > 1) {
    const possibleCb = args[args.length - 1];
    if ('function' === typeof possibleCb) {
      cb = possibleCb;
      options = args.length === 3 ? args[1] : undefined;
    } else {
      options = args[1];
    }
    params = args[0];
  } else if ('object' === typeof args[0]) {
    params = args[0];
  } else if ('function' === typeof args[0]) {
    cb = args[0];
  }
  return { params, options, cb };
}
1024771
function getService(params, callback) {
    if (typeof params === 'function') {
        callback = params;
        params = {};
    }
    var protocol = this.options.Protocol || (util.isBrowser && location.protocol === 'http:' ? 'http:' : 'https:');
    var domain = this.options.ServiceDomain;
    var appId = params.AppId || this.options.appId;
    if (domain) {
        domain = domain.replace(/\{\{AppId\}\}/ig, appId || '').replace(/\{\{.*?\}\}/ig, '');
        if (!/^[a-zA-Z]+:\/\//.test(domain)) {
            domain = protocol + '//' + domain;
        }
        if (domain.slice(-1) === '/') {
            domain = domain.slice(0, -1);
        }
    } else {
        domain = protocol + '//service.cos.myqcloud.com';
    }
    submitRequest.call(this, {
        Action: 'name/cos:GetService',
        url: domain,
        method: 'GET',
        headers: params.Headers,
    }, function (err, data) {
        if (err) {
            return callback(err);
        }
        var buckets = (data && data.ListAllMyBucketsResult && data.ListAllMyBucketsResult.Buckets
            && data.ListAllMyBucketsResult.Buckets.Bucket) || [];
        buckets = util.isArray(buckets) ? buckets : [buckets];
        callback(null, {
            Buckets: buckets,
            statusCode: data.statusCode,
            headers: data.headers,
        });
    });
}
1130470
def _convert_soap_method_args(*args):
    
    soap_args = []
    for arg_n, arg in enumerate(args):
        soap_args.append(('arg' + str(arg_n), arg))
    return soap_args
1334851
function createDefaultMiddleware(connect, options) {
    var middlewares = [];
    if (!Array.isArray(options.base)) {
      options.base = [options.base];
    }
    var directory = options.directory || options.base[options.base.length - 1];
    options.base.forEach(function(base) {
      // Serve static files.
      middlewares.push(connect.static(base));
    });
    // Make directory browse-able.
    middlewares.push(connect.directory(directory));
    return middlewares;
  }
280822
function handleArguments(args) {
  return new Promise(function(resolve, reject) {
    var requires = [];
    var promises = [];

    // check for Promises in args
    if (args && args instanceof Array) {
      args.some(function (arg, i) {
        if ((arg.value === null || typeof(arg.value) == 'undefined') && arg.optional) {
          return true;
        }

        if (arg.value && Array.isArray(arg.value) && arg.optional && arg.value.length == 0) {
          return true;
        }

        if (arg.type == 'string') {
          var s = '"' + arg.value.replace(/"/g, '\\\"') + '"';
          promises.push(Promise.resolve(s));
        } else if (arg.type == 'lambda') {
          promises.push(serializeLambda(arg.value));
        } else if (arg.type == 'lambdaArgs') {
          promises.push(new Promise(function(resolve, reject) {
            handleArrayArgument(arg.value).then(function (result) {
              resolve(result);
            }).catch(reject);
          }));
        } else if (arg.type == 'map') {
          promises.push(Promise.resolve(JSON.stringify(arg.value)));
        } else if (arg.type == 'promise') {
          promises.push(new Promise(function(resolve, reject) {
            arg.value.then(function(val) {
              if (typeof(val) == 'string') {
                if (isNaN(val)) {
                  // a string
                  var s = '"' + val.replace(/"/g, '\\\"') + '"';
                  resolve(s);
                } else {
                  resolve(parseFloat(val));
                }
              } else {
                resolve(val);
              }
            });
          }));
        } else if (arg.value.refIdP) {
          promises.push(arg.value.refIdP);
        } else if (arg.type == 'List') {
          promises.push(Promise.resolve(arg.value.toString()));
        } else if (arg.type == 'array') {
          // simple array argument
          promises.push(handleArrayArgument(arg.value));
        } else if (arg.type == '_eclairSerialize') {
          if (arg.value._eclairSerialize == 'staticProperty') {
            var val = arg.value.ref.name + '.' + arg.value.value;
            promises.push(Promise.resolve(val));
            requires.push({name: arg.value.ref.name, moduleLocation: arg.value.ref.moduleLocation});
          }
        } else if (Array.isArray(arg.value)) {
          // TODO: should we try to wrap the array if it isn't?
          promises.push(new Promise(function (resolve, reject) {
            handleArguments(arg.value).then(function (result) {
              if (result.requires.length > 0) {
                result.requires.forEach(function (r) {
                  requires.push(r)
                });
              }

              resolve('[' + result.args + ']');
            }).catch(reject);
          }));
        } else if (arg.type == '_eclairForceFloat') {
          var val = arg.value.value;
          if (val.toString().indexOf('.') === -1) {
            val = val.toFixed(1);
          }
          promises.push(Promise.resolve(val));
        } else if (arg.type == '_eclairLocal') {
          promises.push(Promise.resolve(arg.value._generateRemote().refIdP));
        } else if (arg.type == 'sparkclassref') {
          // we have a spark class reference, so return its name
          promises.push(Promise.resolve(arg.value.name));
          // add the class to the requires list
          requires.push({name: arg.value.name, moduleLocation: arg.value.moduleLocation});
        } else {
          promises.push(Promise.resolve(arg.value));
        }

        return false;
      });
    }

    Promise.all(promises).then(function(finalArgs) {
      resolve({args: finalArgs, requires: requires});
      //resolve(finalArgs);
    }).catch(function(e) {
      console.log(e);
      reject(e)
    });
  });
}
140881
def services(self, *args, **kwargs):
        
        return self._client.services(*args, scope=self.id, **kwargs)
243665
def get_args
      bin_path = get_binpath
      target   = get_target
      center   = get_center
      jd       = get_jd
      km       = get_km
      check_bin_path(bin_path)
      check_target_center(target, center)
      return [bin_path, target, center, jd, km]
    rescue => e
      raise
    end
573489
function getArguments() {
  var port = 3000;
  var path = '.';
  var args = process.argv.slice(2);

  while (args.length) {
    var arg = args.shift();
    switch (arg) {
      case '-p':
        port = args.shift();
        break;
      default:
        path = arg || path;
    }
  }

  return {
    port: port,
    path: path
  };
}
334745
function (uses, payload, message) {
        var results = [];
        var keys = (uses || []);
        for (var i = 0; i < forced.length; ++i) {
            if (keys.indexOf(forced[i]) === -1) {
                keys.push(forced[i]);
            }
        }

        for (var i = 0; i < keys.length; ++i) {
            if (middlewares[keys[i]] !== undefined) {
                results.push({
                    method: middlewares[keys[i]],
                    params: [payload, message]
                });
            }
        }

        return results;
    }
1143684
function middlewares() {
        app.middlewares = {}
        const basePath = path.join(app.root, '/middlewares')
        let middlewares = app.config.get('express').middlewares
        if (middlewares && Array.isArray(middlewares) && middlewares.length) {
            for (let m of middlewares) {
                let middleware = require(path.join(basePath, m.dest))(app)
                app.middlewares[m.dest.toLowerCase()] = middleware

                if (middleware.length == 4) { //error handler
                    errorHandlers.push(middleware)
                    continue
                }

                if (m.src)
                    server.use(m.src, wrapper(middleware))
                else
                    server.use(wrapper(middleware))
            }
            if (middlewares.length)
                app.drivers.logger.success('Middleware', 'initialized')
        }
    }
239732
def _get_func_args(func):
    """"""
    if isinstance(func, functools.partial):
        return _get_func_args(func.func)
    if inspect.isfunction(func) or inspect.ismethod(func):
        return list(inspect.getargspec(func).args)
    if callable(func):
        return list(inspect.getargspec(func.__call__).args)
906133
def get_current_args(caller_level = 0, func = None, argNames = None):
    
    if argNames is None:
        argNames = getargnames(getargspecs(func))
    if func is None:
        func = get_current_function(caller_level+1)
    if isinstance(func, property):
        func = func.fget if func.fset is None else func.fset
    stck = inspect.stack()
    lcs = stck[1+caller_level][0].f_locals
    return tuple([lcs[t] for t in argNames])
682152
function getFunctionArgs(args) {
        if (args.length > 2) {
            var fnArgs = new Array(args.length - 2),
                i;
            for (i = 2; i < args.length; ++i) {
                fnArgs[i - 2] = args[i];
            }
            return fnArgs;
        }
        return [];
    }
1367494
function createMiddleware(options = {}) {
  const middlewareOptions = Object.assign({}, defaults, options);

  return ({ getState }) => next => action => {
    // Do not process actions without an [RSAA] property
    if (!isRSAA(action)) {
      return next(action);
    }

    return (async () => {
      // Try to dispatch an error request FSA for invalid RSAAs
      const validationErrors = validateRSAA(action);
      if (validationErrors.length) {
        const callAPI = action[RSAA];
        if (callAPI.types && Array.isArray(callAPI.types)) {
          let requestType = callAPI.types[0];
          if (requestType && requestType.type) {
            requestType = requestType.type;
          }
          next({
            type: requestType,
            payload: new InvalidRSAA(validationErrors),
            error: true
          });
        }
        return;
      }

      // Parse the validated RSAA action
      const callAPI = action[RSAA];
      var {
        endpoint,
        body,
        headers,
        options = {},
        fetch: doFetch = middlewareOptions.fetch,
        ok = middlewareOptions.ok
      } = callAPI;
      const { method, credentials, bailout, types } = callAPI;
      const [requestType, successType, failureType] = normalizeTypeDescriptors(
        types
      );

      // Should we bail out?
      try {
        if (
          (typeof bailout === 'boolean' && bailout) ||
          (typeof bailout === 'function' && bailout(getState()))
        ) {
          return;
        }
      } catch (e) {
        return next(
          await actionWith(
            {
              ...failureType,
              payload: new RequestError('[RSAA].bailout function failed'),
              error: true
            },
            [action, getState()]
          )
        );
      }

      // Process [RSAA].endpoint function
      if (typeof endpoint === 'function') {
        try {
          endpoint = endpoint(getState());
        } catch (e) {
          return next(
            await actionWith(
              {
                ...failureType,
                payload: new RequestError('[RSAA].endpoint function failed'),
                error: true
              },
              [action, getState()]
            )
          );
        }
      }

      // Process [RSAA].body function
      if (typeof body === 'function') {
        try {
          body = body(getState());
        } catch (e) {
          return next(
            await actionWith(
              {
                ...failureType,
                payload: new RequestError('[RSAA].body function failed'),
                error: true
              },
              [action, getState()]
            )
          );
        }
      }

      // Process [RSAA].headers function
      if (typeof headers === 'function') {
        try {
          headers = headers(getState());
        } catch (e) {
          return next(
            await actionWith(
              {
                ...failureType,
                payload: new RequestError('[RSAA].headers function failed'),
                error: true
              },
              [action, getState()]
            )
          );
        }
      }

      // Process [RSAA].options function
      if (typeof options === 'function') {
        try {
          options = options(getState());
        } catch (e) {
          return next(
            await actionWith(
              {
                ...failureType,
                payload: new RequestError('[RSAA].options function failed'),
                error: true
              },
              [action, getState()]
            )
          );
        }
      }

      // We can now dispatch the request FSA
      if (
        typeof requestType.payload === 'function' ||
        typeof requestType.meta === 'function'
      ) {
        next(await actionWith(requestType, [action, getState()]));
      } else {
        next(requestType);
      }

      let res;
      try {
        // Make the API call
        res = await doFetch(endpoint, {
          ...options,
          method,
          body: body || undefined,
          credentials,
          headers: headers || {}
        });
      } catch (e) {
        // The request was malformed, or there was a network error
        return next(
          await actionWith(
            {
              ...failureType,
              payload: new RequestError(e.message),
              error: true
            },
            [action, getState()]
          )
        );
      }

      let isOk;
      try {
        isOk = ok(res);
      } catch (e) {
        return next(
          await actionWith(
            {
              ...failureType,
              payload: new InternalError('[RSAA].ok function failed'),
              error: true
            },
            [action, getState(), res]
          )
        );
      }

      // Process the server response
      if (isOk) {
        return next(await actionWith(successType, [action, getState(), res]));
      } else {
        return next(
          await actionWith(
            {
              ...failureType,
              error: true
            },
            [action, getState(), res]
          )
        );
      }
    })();
  };
}
469861
function (methodName, args) {

            var service = this.smd.services[methodName],
                basePath = this.getRootPath(),
                url,
                parameters = this.enumerateParameters(service);

            //if no service target, it sits at the root
            url = basePath + (service.target ? "/" + service.target : "");

            //replace path params where required
            url = this.replacePathParamsInUrl(url, parameters.PATH, args);

            //add any query params
            url = this.addQueryParamsToUrl(url, parameters.URL, args);

            return url;

        }