Return response

The return-response policy aborts pipeline execution and returns either a default or custom response to the caller. Default response is 200 OK with no body. Custom response can be specified via a context variable or policy statements. When both are provided, the response contained within the context variable is modified by the policy statements before being returned to the caller.

Policy statement

XML
<return-response response-variable-name="existing context variable">
<set-header/>
<set-body/>
<set-status/>
</return-response>

Example

XML
<return-response>
<set-status code="401" reason="Unauthorized"/>
<set-header name="WWW-Authenticate" exists-action="override">
<value>Bearer error="invalid_token"</value>
</set-header>
</return-response>

Elements

Element

Description

Required

return-response

Root element.

Yes

set-header

A Set HTTP header policy statement.

No

set-body

A Set body policy statement.

No

set-status

A Set status code policy statement.

No

Attributes

Attribute

Description

Required

response-variable-name

The name of the context variable referenced from, for example, an upstream Send request policy and containing a Response object

Optional.

Usage

This policy can be used in the inbound, outbound, and on-error policy scopes.

Questions? We're always happy to help with any issues you might have! Send us an email to support@youngapp.co or request the demo with our sales team!