Mule 4中attributes.maskedRequestPath的预期值咨询
关于maskedRequestPath值的确认
在你给出的配置场景下,转换输出中的maskedRequestPath值为null。
原因说明
maskedRequestPath的作用是返回请求路径中超出HTTP Listener配置的path前缀之外的剩余部分。只有当Listener显式配置了path属性时,这个字段才会有有效值:
- 比如如果Listener配置的
path为/hello,请求地址为http://localhost:8081/hello/world?abc=def,那么maskedRequestPath的值会是/world。
而你当前的HTTP Listener配置没有指定path属性(默认监听根路径,但无匹配的前缀需要剥离),因此maskedRequestPath没有对应的剩余路径内容,最终返回null,而非"/"。
参考配置与脚本
HTTP Listener配置
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="dc9" > <http:listener-connection host="0.0.0.0" port="8081" /> </http:listener-config>
DataWeave转换脚本
%dw 2.0 output application/json --- { "maskedRequestPath": attributes.maskedRequestPath }
内容的提问来源于stack exchange,提问作者Pierre
相关产品推荐
相关产品推荐

