Building an URL with parts from the path
Asked Answered
J

1

8

Using zuul, is it possible to configure routes to use parts from the path in the url?

This meta code config using normal regexp explains what I'd like to do.

zuul:
  routes:
    foobar:
      path: /foo/{.*}/bar/{.*}
      url: http://foobar/\2/\1

So /foo/123/bar/456 would be routed to http://foobar/456/123

Jacie answered 19/10, 2017 at 9:18 Comment(0)
M
2

You can write your own routing filter, example: https://cloud.spring.io/spring-cloud-netflix/multi/multi__router_and_filter_zuul.html#_how_to_write_a_route_filter

Mope answered 19/10, 2017 at 14:54 Comment(4)
Yeah, of course. But I'm hoping for built in support from the properties files.Jacie
Besides, that might be thought of as routing but it actually terminates the request and sends a new request to the origin/downstream service. I'd like to be able to just stream the request to the correct origin/downstream service. As I think happens with normal routes in Zuul.Jacie
You seem to be able to do this with the new Spring Cloud Gateway, github.com/spring-cloud/spring-cloud-gateway/blob/master/… Is this a possible alternative?Mope
Perhaps. They just released 1.0 and I don't think it's battle proven yet. I'll give it .a test run.Jacie

© 2022 - 2024 — McMap. All rights reserved.