2. Enterprise Integration Patterns

groovy

Version

Executes a Groovy script. The script can access and manipulate data from the request and response. Use this or the Javascript plugin to extend the functions of Membrane by scripting. See: example/groovy for working samples

Syntax

groovy:
location: <string>
src: <string>
groovy:
  location: <string>
  src: <string>

Sample

<api port="2000">
<response>
<groovy>
header.add("X-Groovy", "Hello from Groovy!")
println("Status: ${message.statusCode}")
CONTINUE
</groovy>
</response>
<target url="https://api.predic8.de"/>
</api>
<api port="2000">
    <response>
        <groovy>
            header.add("X-Groovy", "Hello from Groovy!")
            println("Status: ${message.statusCode}")
            CONTINUE
        </groovy>
    </response>
    <target url="https://api.predic8.de"/>
</api>

Attributes

NameRequiredDefaultDescriptionExamples
locationfalseN/AA file or URL location where the content that should be set as body could be foundconf/body.txt
srcfalse---

Can be used in