zoukankan      html  css  js  c++  java
  • 关于请求路径重写

    6.16. The RewritePath GatewayFilter Factory

    The RewritePath GatewayFilter factory takes a path regexp parameter and a replacement parameter. This uses Java regular expressions for a flexible way to rewrite the request path. The following listing configures a RewritePathGatewayFilter:

    Example 41. application.yml

    spring:
      cloud:
        gateway:
          routes:
          - id: rewritepath_route
            uri: https://example.org
            predicates:
            - Path=/foo/**
            filters:
            - RewritePath=/red(?<segment>/?.*), ${segment}
    

      

    For a request path of /red/blue, this sets the path to /blue before making the downstream request. Note that the $should be replaced with $ because of the YAML specification.

    修改“admin_route”路由规则:

            - id: admin_route
              uri: lb://renren-fast
              predicates:
                - Path=/api/**
              filters:
                - RewritePath=/api/(?<segment>/?.*), /renren-fast/${segment}
    

      再次访问:http://localhost:8001/#/login,验证码能够正常的加载了。

  • 相关阅读:
    数据对象映射模式
    策略模式
    适配模式
    注册模式
    单例模式
    工厂模式
    PHP魔法方法的使用
    【转】通过 ulimit 改善系统性能
    HDMI相关知识
    中国三种3G网络频段
  • 原文地址:https://www.cnblogs.com/vincentmax/p/14381789.html
Copyright © 2011-2022 走看看