春季集成http入站网关参数
我想设置一个使用spring-integration
设置端点
@Bean
public MessageChannel reply() {
return new DirectChannel();
}
@Bean
public IntegrationFlow inbound(TestTransformer testTransformer) {
return IntegrationFlows.from(Http.inboundGateway("/foo")
.requestMapping(m -> m.methods(HttpMethod.GET))
.replyChannel("reply")
.requestPayloadType(String.class))
.channel("httpRequest")
.get();
}
@Bean
@ServiceActivator(inputChannel = "httpRequest", outputChannel = "reply")
public Function<Message<?>, String> handler() {
return new Function<Message<?>, String>() {
public String apply(Message<?> message) throws MessagingException {
log.info("myHandler: " + message.getPayload());
log.info("myHandler: " + message.getHeaders());
return "ok";
}
};
}
我有一个springboot 2.2.6
应用程序, http:// localhost:8080/myapp/foo?q = test&amp; q1 = test2
我以json
表单接收参数。
可以在MVC中收到@pathvariable
的东西,例如写作:
return IntegrationFlows.from(Http.inboundGateway("/foo/{name}")
我已经尝试过但不起作用,但我找不到任何文档在谈论这一点(至少使用Java Bean Configuration)
谢谢
I have a SpringBoot 2.2.6
application and I would like to set an endpoint with spring-integration
therefore I have the follow configuration:
@Bean
public MessageChannel reply() {
return new DirectChannel();
}
@Bean
public IntegrationFlow inbound(TestTransformer testTransformer) {
return IntegrationFlows.from(Http.inboundGateway("/foo")
.requestMapping(m -> m.methods(HttpMethod.GET))
.replyChannel("reply")
.requestPayloadType(String.class))
.channel("httpRequest")
.get();
}
@Bean
@ServiceActivator(inputChannel = "httpRequest", outputChannel = "reply")
public Function<Message<?>, String> handler() {
return new Function<Message<?>, String>() {
public String apply(Message<?> message) throws MessagingException {
log.info("myHandler: " + message.getPayload());
log.info("myHandler: " + message.getHeaders());
return "ok";
}
};
}
Now if I call the enpoint passing params as http://localhost:8080/MyApp/foo?q=test&q1=test2
I receive the parameters in a JSON
form.
Is possible to receive something like @PathVariable
in the MVC for example writing:
return IntegrationFlows.from(Http.inboundGateway("/foo/{name}")
I have tried it but doesn't work and I canno't find any docs talking about that (at least with java bean configuration)
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许:
更有用...文档充满了XML配置,我读了它,但是我无法将它们全部转移到
java dsl
中Maybe:
is more usefull... The docs is full of xml config and I read it but I'm not able to trasnform them all into
java DSL