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 variable support for call mediator and improve synapse expression #2250

Merged
merged 5 commits into from
Dec 5, 2024

Conversation

arunans23
Copy link
Member

Purpose

Describe the problems, issues, or needs driving this feature/fix and include links to related issues in the following format: Resolves issue1, issue2, etc.

This PR adds variable support to Call mediator target so that the response elements (payload, headers and attributes) can be stored in a variable.

          <call>
            <endpoint>
               <http method="POST" uri-template="https://run.mocky.io/v3/fc50337e-e54d-45a7-8bc8-f5c1b53b2519"/>
            </endpoint>
            <target type="variable">{${params.funcParams.targetVariable}}</target>
         </call>

The Synapse expression has been improved to handle Map type variables so that the above stored response elements can be accessed.

Eg:

         <log level="simple">
            <property name="messagenew" expression="${var.resultMocky['payload']}"/>
            <property name="statusCode" expression="${var.resultMocky['attributes'].statusCode}"></property>
            <property name="content-length" expression="${var.resultMocky['headers']['Content-Length']}"></property>
         </log>

@@ -459,6 +466,18 @@ public void insertJson(MessageContext synCtx, Object sourceJsonElement, SynapseL
}
break;
}
case EnrichMediator.VARIABLE:
if (action.equalsIgnoreCase(ACTION_REPLACE)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we get a requirement to enrich to variables in other mediator, this may lead to a conflict. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are not giving priority to the Enrich mediator going forward, we don't have to consider this.

@arunans23 arunans23 merged commit c468678 into wso2:master Dec 5, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants