mkopylec / charon-spring-boot-starter

Reverse proxy implementation in form of a Spring Boot starter.
Apache License 2.0
240 stars 54 forks source link

Dynamic route request #139

Open sendreams opened 1 year ago

sendreams commented 1 year ago

currently, should setting the mapping rule on startup.

In some cases, I hope to dynamically forward in the controller according to the business situation

@GetMapping(value = "/route") ResponseEntity<?> route(@PathVariable String biz) { if (biz == '1') forwordTo("http://localhost:8091/biz")
else if (biz == "2") forwordTo("http://localhost:8090/biz") }

i have been tested restTemplate to route the request. but if the client does not pass the information according to the specification, this code will throw an exception, such as get request with requestbody.

image the end uri is a GET method with requestbody, an exception message was raised.

I hope the code like this

Router.forward(request, url)

is any way here? thanks.