gateway

route配置

复制代码
 @Bean
    public RouteLocator myRoute(RouteLocatorBuilder builder){
        return builder.routes()
                .route("deal-server",p->p
                                .method("GET").and()
                                .path("/deal/**")
                        .uri("http://localhost:8888")
                        )
                .route("chat-server",predicateSpec -> {
                    return predicateSpec.method("GET")
                            .and().path("/chat/**")
                            .uri("http://localhost:8848");
                })
                .build();
    }

application

复制代码
spring:
  config:
    import: nacos:gateway-server.properties
  cloud:
    nacos:
      discovery:
        server-addr: http://localhost:8848
      config:
        server-addr: http://localhost:8848
  main:
    web-application-type: reactive
  application:
    name: gateway-server

一些Ant路径模式的常见用法

单字符匹配 ?

? 代表匹配路径中的一个字符。

例如:/user? 可以匹配 /user1、/user2,但不能匹配 /users。

多字符匹配 *

  • 代表匹配路径中的任意数量的字符(包括零个字符)。
    例如:/users/* 可以匹配 /users/123、/users/profile,但不能匹配 /users。

多级路径匹配 **

** 代表匹配路径中的任意数量的路径段,包括零个路径段。

例如:/users/** 可以匹配 /users/、/users/123、/users/123/profile。

路径分隔符 /

/ 用于分隔路径中的各个部分。

例如:/users/profile 匹配路径 /users/profile。

相关推荐
xrkhy2 小时前
微服务之Gateway网关(1)
微服务·架构·gateway
无名客05 天前
SpringCloud中的网关(Gateway)的作用是什么?
spring·spring cloud·gateway
smilecold7 天前
SpringCloud 入门 - Gateway 网关与 OpenFeign 服务调用
spring cloud·gateway
INFINI Labs9 天前
Elasticsearch 备份:方案篇
大数据·elasticsearch·搜索引擎·gateway·snapshot·backup·ccr
纤瘦的鲸鱼9 天前
Spring Gateway 全面解析:从入门到进阶实践
java·spring·gateway
INFINI Labs12 天前
如何使用 INFINI Gateway 对比 ES 索引数据
大数据·elasticsearch·gateway·easysearch
m0_6515939113 天前
位置透明性、Spring Cloud Gateway与reactor响应式编程的关系
java·spring cloud·系统架构·gateway
nvd1114 天前
使用gateway api来实现GKE 的pods 从外部访问
gateway·googlecloud
罗不俷14 天前
【Kubernetes】(二十)Gateway
容器·kubernetes·gateway
月夕·花晨15 天前
Gateway-过滤器
java·分布式·spring·spring cloud·微服务·gateway·sentinel