Tree Gateway - Filters

We are assuming in these examples, that our test gateway will be running at 'http://gateway.address.com'.

Custom Filter

Filter Example --- name: MyFilteredAPI version: 1.0.0 path: filtered/ proxy: target: host: http://httpbin.org filter: middleware: name: myFilter module.exports = function (request, response) { return req.query.denyParam !== '1'; };

This sample uses a filter to check if the current request should proceed or not.

That example will avoid that a request containing the query parameter 'denyParam=1' proceed. Eg: Eg. curl http://gateway.address.com/filtered/get?denyParam=1

IP Whitelist filter

Whitelist Example --- name: MyFilteredAPI version: 1.0.0 path: filtered/ proxy: target: host: http://httpbin.org filter: middleware: name: ipFilter options: whitelist: - 127.0.0.1 - "::1" statusCode: 403 message: IP Filtered database: checkInterval: 'one minute' key: 'MyFilteredApi:whitelist'

This sample uses the ipfilter (included into Tree Gateway distribution) to check if the current request should proceed or not.

We enable access only to localhost requests and configure a database pooling for aditional IPs that should be allowed.

IP Blacklist filter

Blacklist Example --- name: MyFilteredAPI version: 1.0.0 path: filtered/ proxy: target: host: http://httpbin.org filter: middleware: name: ipFilter options: blacklist: - 127.0.0.1 - "::1"

This sample uses the ipfilter (included into Tree Gateway distribution) to check if the current request should proceed or not.

We enable access to all request except to requests coming from localhost.