使用 http 入站网关,我可以使用 SPEL 指定有效负载表达式,该表达式将访问 header、requestParams 和 pathVariables。如何同时包含 POST 中的正文?我目前拥有的一个例子是
<int-http:inbound-gateway path="/document/{product}/{id}/blah"
supported-methods="GET"
request-channel="documentService.blah"
reply-channel="httpReplyChannel"
message-converters="jsonMessageConverter"
header-mapper="defaultHttpHeaderMapper"
payload-expression="new RequestDTO(
#pathVariables.product,
#pathVariables.id,
#requestParams['optionalParam'],
headers.get('headerKey')) />
这工作正常,但是我想向 RequestDTO 构造函数添加一个附加参数,该参数是实际的帖子正文(显然我将更改该方法)并将其序列化为适当的类型。
这可能吗?提前致谢。
对的,这是可能的。负载表达式使用一个评价语境 with Http实体 as 根对象,
#requestParams and #path变量变量。
因此,如果将其更改为 POST,您可以获得正文!:
payload-expression="new RequestDTO(
#pathVariables.product,
#pathVariables.id,
#requestParams['optionalParam'],
headers.get('headerKey'),
body)"
这只是因为Http实体有那个吸气剂!
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)