zoukankan      html  css  js  c++  java
  • 通过curl测试断言predicate

    1、getway.yml配置

    server:
      port: 9527
    
    spring:
      application:
        name: cloud-gateway
      cloud:
        gateway:
          routes:
            - id: payment_routh #payment_route    #路由的ID,没有固定规则但要求唯一,建议配合服务名
              #uri: http://localhost:8001          #匹配后提供服务的路由地址
              uri: lb://springcloud-product-providers
              predicates:
                - Path=/product/provider/get/**         # 断言,路径相匹配的进行路由
                #- After=2021-05-31T10:02:46.918+08:00[Asia/Shanghai]         # 断言,路径相匹配的进行路由
                #- Before=2020-02-05T15:10:03.685+08:00[Asia/Shanghai]         # 断言,路径相匹配的进行路由
                #- Between=2020-02-02T17:45:06.206+08:00[Asia/Shanghai],2020-03-25T18:59:06.206+08:00[Asia/Shanghai]
                - Cookie=username,zzyy
                - Header=X-Request-Id, d+  # 请求头要有X-Request-Id属性并且值为整数的正则表达式
                - Host=**wen.com
                #- Method=GET
                - Query=id, d+  # 要有参数名username并且值还要是整数才能路由
            - id: payment_routh2 #payment_route    #路由的ID,没有固定规则但要求唯一,建议配合服务名
              #uri: http://localhost:8001          #匹配后提供服务的路由地址
              uri: lb://springcloud-product-providers
              predicates:
                - Path=/provider/discovery/**         # 断言,路径相匹配的进行路由
    
    eureka:
      instance:
        hostname: cloud-gateway-service
      client: #服务提供者provider注册进eureka服务列表内
        service-url:
          register-with-eureka: true
          fetch-registry: true
          defaultZone: http://eureka7001.com:7001/eureka

    2、curl的拼接

    curl http://localhost:9527/product/provider/get/1?id=2 -H "X-Request-Id:1" -H "Host:xiangwen.com" --cookie "username=zzyy"

    3、结果

  • 相关阅读:
    A. Vasya and Book
    B. Curiosity Has No Limits
    A. Link/Cut Tree
    C. Yuhao and a Parenthesis
    D2. Magic Powder
    B. Approximating a Constant Range
    51nod1185 威佐夫游戏 V2 (模拟乘法)
    博弈论(巴什博奕,威佐夫博弈,尼姆博弈,斐波那契博弈)
    sg函数模板
    D.Starry的神奇魔法(矩阵快速幂)
  • 原文地址:https://www.cnblogs.com/wenwenzuiniucha/p/14827450.html
Copyright © 2011-2022 走看看