Spring-Gateway 路由配置

2022年9月21日12:15:22
pring:
  cloud:
    gateway:
      routes:
      - id: before_route
        uri: http://localhost:8001
        predicates:
      # 在某个时间之前的请求才会被转发到 http://localhost:8001,
          - Before=2017-01-20T17:42:47.789-07:00[America/Denver]
      # 在某个时间之后的请求才会被转发
      #   - After=2017-01-20T17:42:47.789-07:00[America/Denver]
      # 在某个时间段之间的才会被转发
      #   - Between=2017-01-20T17:42:47.789-07:00[America/Denver], 2017-01-21T17:42:47.789-07:00[America/Denver]

      # 名为chocolate的表单或者满足正则ch.p的表单才会被匹配到进行请求转发
      #   - Cookie=chocolate, ch.p
    
      # 携带参数X-Request-Id或者满足\d+的请求头才会匹配
      #   - Header=X-Request-Id, \d+

      # 按Host主机名匹配
      #   - Host=qiying.com:8080
	
      # 按请求方法进行匹配,只有GET方法才会匹配
      #   - Method=GET
      # 按请求路径进行匹配
      #   - Path=/app/{path}
	
        filters:
      # 在请求路径前加上自定义的路径
      #   - PrefixPath=/app
      # 重写请求路径
      # 访问localhost:8080/test, 请求会转发到localhost:8001/app/test
      #   - RewritePath=/test, /app/test
      #   - RewritePath=(?<oldPath>^/), /app$\{oldPath}
      # 通过模板设置路径
      #   - SetPath=/app/{path}
  • 作者:llyilo
  • 原文链接:https://blog.csdn.net/llyilo/article/details/123053174
    更新时间:2022年9月21日12:15:22 ,共 773 字。