Write Custom Edge Rules

In addition to creating new rules by choosing built-in conditions and actions on the page, Edge offers a more flexible and powerful way: write custom Edge rules.

For instance, for a rule that involves the request to access the /hello address, set a response header Custom, to add character string hello to the value in the request Cookie UserID.

This kind of rule is impossible to create via the current interface, but can be realized easily through the custom Edge rule.

Click the Add Edge Language Rules at the Beginning of This Page button, and a textbox appears for code input, where code highlighting and function prompt functions are available, and so is the vim edit mode supporting vim shortcuts:

Here, input the custom Edge rule. For details about grammars and functions in Edge language, please refer to Edge Language User Manual,

No further explanation is necessary.

If the code input is wrong, the error will be reported while it is saved and tested.

On the Page Rules page, Edge codes can be written at two places and executed either before or after all Page Rules,

but not in between.