Skip to content

Request Filter

thiagobustamante edited this page May 27, 2017 · 6 revisions

A Filter is a function that receives the request and the response object from the gateway and must return a boolean value to inform if the given request should target the destination API or if it should be ignored.

Each filter must be defined on its own .js file.

Example:

/**
 * Where request and response are the original request and response objects created by [http](https://nodejs.org/api/http.html) module.
 */
module.exports = function (request, response) {
  return req.query.denyParam !== '1';
};

You can configure a request filter middleware through:

  • Admin Rest API: POST /midleware/filters
  • SDK: sdk.middleware.addFilter(name, fileName);
  • CLI: treeGatewayConfig middleware filter -a <name> ./filename.js
Clone this wiki locally