Gateway programming model and GatewayScript

The Gateway programming model and GatewayScript support the ECMAScript language specification.

The programming model implements much of the Ecma Standard for DataPower®. ECMAScript is based on original, internet technologies, including JavaScript and JScript. For example, the Gateway programming model supports ECMAScript regular expressions.

In addition to the features of ECMAScript, the Gateway programming model implements block scoping, and more security measures in its system code. Block scoping ensures that variables are not visible outside of code blocks. More provisions for security are described in a section on security in GatewayScript.

GatewayScript programs

Gateway script includes ECMAScript, CommonJS, and DataPower-specific GatewayScript APIs. Therefore, when you write programs for GatewayScript, use programming techniques that conform to the following specifications.
  • The ECMAScript language specification defines the structures and mechanisms of the programming language. GatewayScript supports many ECMAScript 2015 (ES6) features by default, including generators, promises, and template strings. For more information, see ECMAScript 2015 (ES6) in Node.js (8.9.4 LTS).
    • One important restriction on GatewayScript programs is the use of ECMAScript in strict mode. Strict mode provides a means for controlling programming behavior so that they are more secure, reliable, readable, and manageable.
    • All characters in GatewayScript files must be encoded in the UTF-8 character set.
  • CommonJS 1.0 is the CommonJS specifications define programming interfaces that address how modules are written to be interoperable among systems. You can create custom modules by following the CommonJS specifications and can access custom modules based on precedence rules for require modules.
  • GatewayScript supports DataPower-specific objects and methods and more programming structures. For example, the Document Object Model (DOM) Core node interface defines a set of objects and interfaces for accessing and manipulating document objects.
  • The API gateway supports a different context object, which is specific to API management.

    The GatewayScript APIs for API management can access and manipulate the variables in the API context during execution of the API assembly rule. The GatewayScript APIs are used by the GatewayScript assembly action of the API gateway.