Tools, FAQ, Tutorials:
'return-response' Policy Statement
How to use the "return-response" Policy statement to build the response from scratch for an Azure API service operation?
✍: FYIcenter.com
The "return-response" Policy Statement allows you to stop the Azure API processing immediately and return with the given response.
The "forward-request" statement can be used in three ways:
1. Return an empty response with status of 200:
<return-response/>
2. Return a new response constructed with "set-status", "set-headers" and "set-body" child policy statements:
<return-response> <set-status... /> <set-header ... /> <set-body .../> </return-response>
For example, the following "inbound" policy returns a new response with status of 401:
<inbound> <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> <inbound>
3. Return an existing response created previously:
<return-response response-variable-name="existing context variable"> </return-response>
For example, the following "inbound" policy returns an existing response stored in a context variable:
<inbound> <return-response response-variable-name="context.Variables["loginResponse"]"> </return-response> <inbound>
⇒ 'send-request' Policy Statement
⇐ 'mock-response' Policy Statement
2018-01-13, 4705🔥, 0💬
Popular Posts:
How To Access a Global Variable inside a Function? in PHP? By default, global variables are not acce...
How to use .NET CLR Types in Azure API Policy? By default, Azure imports many basic .NET CLR (Common...
How to use "{{...}}" Liquid Codes in "set-body" Policy Statement? The "{{...}}" Liquid Codes in "set...
How to use the Atom Online Validator at w3.org? w3.org feed validation service is provided at http:/...
How to extend json.JSONEncoder class? I want to encode other Python data types to JSON. If you encod...