How to change the status code of a response

In Membrane, status codes can be modified using the groovy element. For more in-depth scripting guidance, visit: Scripting.

Ingredients

Configuration

<api port="2000">
    <response>
        <if test="statusCode == 401" language="SpEL">
            <groovy>exc.getResponse().setStatusCode(404)</groovy>
        </if>
    </response>
    <target url="http://localhost:2001" />
</api>

<api port="2001">
    <return statusCode="401" />
</api>

Resources

groovy Example Documentation
If Example Documentation