一、 在一个微服务节点的predicates下配置多个path: - path=/test/batis/test,/test/testjmeter,具体配置如下:
spring:
  
  application:
    name: xxxx
  profiles:
    active: dev
  cloud:
    inetutils:
      preferred-networks: ^192\.168\.[\d]\.[\d]+$
      
    gateway:
      enabled: true
      httpclient:
        connect-timeout: 1000
        response-timeout: 5s
      default-filters:
        - stripprefix=0
        - name: hystrix
          args:
            name: fallbackcmd
            fallbackuri: forward:/fallback
      discovery:
        locator:
          # 是否和服务注册与发现组件结合,设置为 true 后可以直接使用应用名称调用服务
          enabled: true
      # 路由(routes:路由,它由唯一标识(id)、目标服务地址(uri)、一组断言(predicates)和一组过滤器组成(filters)。filters 不是必需参数。)
      routes:
        - id: management-admin
          uri: lb://management-admin
          predicates:
            - path=/admin/**,/openbase/**二、 在请求头中新增header参数,yml文件配置如下:
spring:
  application:
    name: openapi-gate-way
  profiles:
    active: dev
  cloud:
    inetutils:
      preferred-networks: ^192\.168\.[\d]\.[\d]+$
    gateway:
      enabled: true
      httpclient:
        connect-timeout: 3000
        response-timeout: 5s
      default-filters:
        - stripprefix=0
        - name: hystrix
          args:
            name: fallbackcmd
            fallbackuri: forward:/fallback
      routes:
        
        - id: openapi-base          
          uri: lb://openapi-base         
          predicates:            
            - path=/openbase/**
          filters:
            # 新增请求头参数
            - addrequestheader=name, 小明三、自定义filter中新增请求头参数:
@component
public class demofilter implements gatewayfilter, ordered {
    @override
    public mono<void> filter(serverwebexchange exchange, gatewayfilterchain chain) {
    
        serverhttprequest request = exchange.getrequest().mutate()
                .header("name", "xxx")
                .header("age", 12)
                .build();
        return chain.filter(exchange.mutate().request(request).build());
    }
    @override
    public int getorder() {
        return 1;
    }
}
 
             我要评论
我要评论 
                                             
                                            ![[ 云计算 | AWS 实践 ] Java 如何重命名 Amazon S3 中的文件和文件夹](https://images.3wcode.com/3wcode/20240802/s_0_202408020028483641.png) 
                                            
发表评论