I would like to enable or disable an HTTP proxy dynamically based on a YAML property.
service:
useHttpProxy: "true"
HTTP Request Config:<http:request-config name="service-config">
<http:request-connection
protocol="HTTPS"
host="${service.host}"
port="${service.port}"
proxyConfig="#[
if (Mule::p('service.useHttpProxy') == 'true')
'proxyConfig'
else
null
]" />
</http:request-config><http:proxy
name="proxyConfig"
host="${proxy.host}"
port="${proxy.port}" />
I get the following error:
Unable to convert 'proxyConfig' with class 'java.lang.String'
to class 'HttpProxyConfig'
WriterExecutionException:
Unable to convert 'proxyConfig' with class 'java.lang.String'
to class 'HttpProxyConfig'
My understanding is that the proxyConfig attribute expects an HttpProxyConfig object, while my expression returns a String ("proxyConfig").
Is it possible to dynamically set the proxyConfig attribute using a DataWeave expression? Because I don't like to have two separate http:request-config definitions (one with a proxy and one without) and select the appropriate one at runtime
Thank you in advance!
#MuleSoft
this way works if(Mule::p('phoenix-sys.useHttpProxy') == "true")
app.registry.proxyConfig //or app.registry['proxyConfig']