spring-cloud/spring-cloud-gateway

Forward Routing filter doesn't support path parameters for local forwarding

Open

#2.092 geöffnet am 29. Dez. 2020

Auf GitHub ansehen
 (14 Kommentare) (2 Reaktionen) (0 zugewiesene Personen)Java (3.204 Forks)batch import
enhancementhelp wanted

Repository-Metriken

Stars
 (4.284 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 21h) (18 gemergte PRs in 30 T)

Beschreibung

Describe the bug I am using forward scheme in my route to forward the request to local controller defined in the gateway application. My controller's API path is something like this:

/api/v1/service/{id}/path where id is path parameter. As per the documentation of Forward Routing filter, the path part of the request URL is overridden with the path in the forward URL. That means that whatever was mentioned in the forward:/mycustompath will be added to the url. In this case, i can't route the request to my controller where id will change for each request.

Is there a way to achieve this? We were earlier using Spring cloud zuul and we are now migrating to spring cloud gateway and this is not working for us. I am trying to write a custom filter for this where i modify the correct path in the filter. Is this correct approach for this?

Sample image

Contributor Guide