Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
不同url的spring云网关映射_Spring_Spring Cloud Gateway - Fatal编程技术网

不同url的spring云网关映射

不同url的spring云网关映射,spring,spring-cloud-gateway,Spring,Spring Cloud Gateway,我是SpringCloudGateway的新手。我有以下情况: 我想要映射的路径:/myapp/v1/ms1/** - id: microservice1 predicates: - Path=/myapp/v1/ms1/** uri: http://localhost:8090/api/v1/ms1/** 目标url:http://localhost:8080/api/v1/ms1/** - id: microservice1 predicates: - Path=/my

我是SpringCloudGateway的新手。我有以下情况:

我想要映射的路径:/myapp/v1/ms1/**

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

- id: microservice1
  predicates:
  - Path=/myapp/v1/ms1/**
  uri: http://localhost:8090/api/v1/ms1/**
那么对于http://gateway:port/myapp/v1/ms1/message ,我想重定向到http://localhost:8090/api/v1/ms1/message.

所以这应该是自然发生的,或者我需要使用任何过滤器,比如重写路径过滤器

我在寻求建议


提前感谢。

我认为您需要使用一个自定义过滤器或由StripPrefixGatewayFilterFactory或RewritePathGatewayFilterFactory提供的过滤器

最简单的方法是使用RewritePathGatewayFilterFactory


如果使用StripPrefixGatewayFilter,则需要将路径从/myapp/v1/ms1/**更改为/myapp/api/v1/ms1/**。

简单的方法是使用筛选器重写路径