Skip to content

Dynamic route request #139

@sendreams

Description

@sendreams

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions