不同url的spring云网关映射
我是SpringCloudGateway的新手。我有以下情况: 我想要映射的路径:/myapp/v1/ms1/**不同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
- 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/**。简单的方法是使用筛选器重写路径