0

Is there any way to route all request to specific URI to another projects rest controller? consider the code below:

    @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");
}
}

I want to route all request of /hello to another project rest controller endpoint: localhost:9080/hello but without XML it cant be possible.

primElite
  • 11
  • 2

1 Answers1

0

See matchOnUriPrefix of jetty and undertown components and bridgeEndpoint option of HTTP component.

This is what you need:

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

Also see this another answer to more details https://stackoverflow.com/a/67893371/11052487