油门在Apache骆驼/春天
如何在骆驼中的所有路线中添加节气门,
@Component
public class MyRestRoute extends RouteBuilder {
@Value("${spring.application.name}")
private String appName;
@Value("${spring.application.description}")
private String description;
@Value("${spring.application.version}")
private String appVersion;
@Override
public void configure() throws Exception {
restConfiguration().apiContextRouteId("swagger").contextPath(System.getenv("CONTEXT_PATH"))
.apiContextPath("/swagger").component("servlet")
.apiProperty("api.title", appName)
.apiProperty("api.description", description)
.apiProperty("api.version", appVersion)
.apiProperty("host", "localhost")
.apiProperty("port", "8080")
.apiProperty("schemes", "http");
rest("/transfers/{transfer_id}")
.post().type(Request.class).id("id-limits").description("transfer").bindingMode(RestBindingMode.auto)
.skipBindingOnErrorCode(true)
.param().name("transfer_id").type(RestParamType.path).description("transferId").endParam()
.produces(MediaType.APPLICATION_JSON_VALUE)
.to("direct:transferRoute);
rest("/accounts")
.get().id("id-limits").description("Get Accounts").bindingMode(RestBindingMode.auto)
.skipBindingOnErrorCode(true)
.param().name("account_id").type(RestParamType.query).description("account_id").endParam()
.param().name("document").type(RestParamType.query).description("document").endParam()
.produces(MediaType.APPLICATION_JSON_VALUE)
.to("direct:accountsRoute));
}
}
而骆驼的所有路线都可以接收到更多的REST Resource_Path,如何在所有主要路线中插入油门。 我知道我可以在.from(“ Direct:TransferRoute”)和.from(“ Direct:AccountRoute”)中插入。 我可以在骆驼中这样做,还是使用弹簧更安全?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,我认为不可能在全球范围内做。
恐怕您必须以每次路线进行操作。
作为(非常愚蠢的)解决方法,您仍然可以想象这样的事情。
As far as I know, I do not think it is possible to do it globally.
I'm afraid you have to do it on a per-route basis.
As a (pretty stupid) workaround, you can yet imagine something like this.
也许您可以使用interceptor
Maybe you can use interceptor https://camel.apache.org/components/3.17.x/eips/intercept.html#_using_intercept