簡體   English   中英

使用 apache 駱駝將 url 路由到外部 rest 控制器

[英]route url to external rest conroller using apache camel

有沒有辦法將所有請求路由到特定 URI 到另一個項目 rest controller? 考慮下面的代碼:

    @Component
public class CamelSportsRouteBuilder extends RouteBuilder {

    @Override
    public void configure() throws Exception {
        restConfiguration()
                .component("servlet")
                .bindingMode(RestBindingMode.auto);

        rest().path("/hello").get().route()
                .toD("localhost:9080/hello");
}
}

我想將/hello的所有請求路由到另一個項目 rest controller 端點: localhost:9080/hello但沒有 XML 這是不可能的。

請參閱 jetty 和 undertown 組件的 matchOnUriPrefix 以及 HTTP 組件的 bridgeEndpoint 選項。

這就是你需要的:

from("undertow:http://localhost:8080/hello?matchOnUriPrefix=true")
.to("http4://localhost:8081/hello?bridgeEndpoint=true");

另請參閱this another answer to more details https://stackoverflow.com/a/67893371/11052487

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM