Go to new doc!

+49 228 5552576-0




Executes a Javascript. The script can access and manipulate data from the request and response. Use this or the Groovy plugin to extend the functions of Membrane by scripting. See the samples in examples/javascript.

Can be used in

spring:beans, api, bean, if, interceptor, internalProxy, proxy, registration, request, response, serviceProxy, soapProxy, stompProxy, swaggerProxy, transport and wsStompReassembler




The following imports are automatically added to your script.

        import static com.predic8.membrane.core.interceptor.Outcome.*
        import com.predic8.membrane.core.http.*
These provide access to the static members of the Outcome enum and the classes contained in the http package.


The following variables can be accessed within a script.

Name Class Description
exc com.predic8.membrane.core.exchange.Exchange The Exchange class provides, among others, access to the Request, Response and their corresponding Headers.
message com.predic8.membrane.core.http.Message Message is the superclass of a request or a response. Depending on the flow the message contains data from the request or the response.
header com.predic8.membrane.core.http.Header The header object allows access to the HTTP header fields. You can remove, add and change fields.
body com.predic8.membrane.core.http.Body The body of the message.
json java.util.Map If the message contains a body of the type application/json this varible will contain the JSON as a Map. Use it only to read the JSON document.
flow com.predic8.membrane.core.interceptor.Flow REQUEST or RESPONSE
properties java.util.Map The properties of the exchange object.
spring org.springframework.context.ApplicationContext The Spring application context hosting the router instance (or null, if the router is not hosted by Spring).

Return Value

A script can return a value that is put into the message body or the value can influence the processing of an exchange.

Class Description Example
java.util.Map The map is converted into JSON and put into the message body. [id:7, city:'Bonn']
com.predic8.membrane.core.http.Response The response is put into the exchange and the flow returns to the client. Response.ok().body('Done!').build()
com.predic8.membrane.core.interceptor.Outcome The enumeration controls the flow of the exchange. With CONTINUE the processing goes on. With RETURN the flow is returned to the client. And ABORT terminates with an error. CONTINUE, RETURN, ABORT
java.util.String Puts the string into the message body and continues. 'Done.'