Scripting

Throughout Membrane, certain plugins like:

support expressions written in Javascript, Groovy or SpEL.

Examples

...

Context Attributes

When using Membranes scripting capabilities, a set of pre-defined attributes and APIs are available to provide access to useful information about the current context:

Outcomes

Outcomes are enums that depict the current state of the request/response flow.
Next to the enum class itself Outcome, the individual enum states are available as well.

Outcome Description
RETURN Changes the direction of flow. The request handling mechanisms of the active plugins get activated.
CONTINUE Continues the flow.
ABORT Aborts the current flow, the direction is changed and the abort handling mechanisms of the active plugins get activated.

Exchange

The exc keyword grants access to the current Exchange object, housing request and response information.

Message

The message keyword is a shortcut to exc.getRequest()/exc.getResponse().
Depending on direction of flow, message can stand for a request or response object.

Params

The params keyword can be used to access request query parameters.

JSON

If the body of a message is of type application/json, json is a parsed JSON object representation of the body's JSON document.

Flow

The flow keyword houses the Flow enum. Values are REQUEST and RESPONSE.
These stand for the direction of flow.

Properties

The properties keyword is a shortcut to exc.getProperties().

Spring

The spring keyword grants access to Membrane's Spring ApplicationContext.