Expression

Description

The Expression policy allows you to execute arbitrary JavaScript code in secured shared memory or “sandbox”.

Usage

To enable the Expression policy, add expression in gateway.config.yml in the policies section.

policies:
  - expression
  # other policies

Example

pipelines:
  api:
    policies:
      -
        expression: # policy name
          - action:    # array of condition/actions objects
              jscode: 'req.url = "/new/url"; ' #  code to execute against EG Context

Options Reference

  • jscode:
    • Valid JS code to execute. Note that egContext object will be used as global object for code. All Node.JS global variables like process, require etc. will not be available for security reasons