SpringCloud 中 Gateway 的基本使用

依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-gateway</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>

yaml 配置文件

spring:
  cloud:
    gateway:
      routes:
        - id: xxooroute
          # 转发到的的url
          uri: http://localhost:8181
          predicates:
            # 需要转发的path
            - Path=/xx/**
            # 有此参数才转发
            - Query=id,.
            # 为此请求方式才转发
            - Method=get
          filters:
            # 去掉上述的一个前缀,在拼接到上述uri中
            - StripPrefix=1

自定义路由

https://wwp666.blog.csdn.net/article/details/119990311

自定义过滤器

https://wwp666.blog.csdn.net/article/details/119990373

posted @ 2022-03-07 18:04  叕叕666  阅读(45)  评论(0)    收藏  举报