Mule 4 – Add Custom Response Headers

Recently MuleSoft has officially released Mule 4. Many things have changed in Mule 4. Recently I was involved in a project to upgrade Mule 3.x application to Mule 4.x.

Use Case:

The use case was to return custom response header “x-warning” for some of the APIs so that consumers can identify if the API is deprecated or not. Previously, we had used “set-property” but with Mule 4 things have changed. We came up with following flow which can be referenced from some specific APIs.

Now, following HTTP listener will return the header in the response.

This is just one use case, but above approach can be used to add one or more custom response headers based on project specific use cases.

Leave a Reply

Your email address will not be published. Required fields are marked *