Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add policy to change response (body, header, statuscode) based on context (e.g. backend response code) #31

Open
davihern opened this issue Mar 8, 2023 · 0 comments
Assignees

Comments

@davihern
Copy link
Collaborator

davihern commented Mar 8, 2023

Some policy similar to:

    <choose>
        <when condition="@(context.Response.StatusCode == 500)">
            <return-response>
                <set-status code="510" reason="Internal APIM error captured" />
                <set-header name="CustomHeader" exists-action="override">
                    <value>Error captured and sanitized by APIM</value>
                </set-header>

@{
var response = context.Response.Body.As();

    return Regex.Replace(response, "A", "*");
  }</set-body>
            </return-response>
        </when>
    </choose>
    <find-and-replace from="SECRET" to="*S*" />
@davihern davihern converted this from a draft issue Mar 8, 2023
@davihern davihern moved this from 📋 Backlog to 🏗 In progress in APIM demo Mar 8, 2023
@davihern davihern self-assigned this Mar 8, 2023
@davihern davihern moved this from 🏗 In progress to 👀 In review in APIM demo Mar 8, 2023
@davihern davihern moved this from 👀 In review to ✅ Done in APIM demo Mar 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant