spring cloud gateway mapping for different url

549 views Asked by At

I am a newbee for spring cloud gateway. I have the below scenario:

the path I wanted to map : /myapp/v1/ms1/**

target url : http://localhost:8080/api/v1/ms1/**

- id: microservice1
  predicates:
  - Path=/myapp/v1/ms1/**
  uri: http://localhost:8090/api/v1/ms1/**

so for the http://gateway:port/myapp/v1/ms1/message , I want to redirect to http://localhost:8090/api/v1/ms1/message.

so this should happen naturally or do I need to use any filter like RewritePath filter.

I am looking for suggestions.

Thanks in Advance.

1

There are 1 answers

0
pigman On

i think you need to use a custom filter or filter provided by StripPrefixGatewayFilterFactory or RewritePathGatewayFilterFactory.

the most simple way is to use RewritePathGatewayFilterFactory.

if you use the StripPrefixGatewayFilter ,you need to change you Path from /myapp/v1/ms1/** to /myapp/api/v1/ms1/**.