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。

相关推荐
道清茗12 小时前
【Kubernetes知识点问答题】Kustomize、CRD 与 Gateway API
容器·kubernetes·gateway
专注_每天进步一点点12 小时前
xxop网关 → APISIX集群(ApisixRoute) → 业务gateway模块 和 Serverless架构 区别和联系
架构·serverless·gateway
专注_每天进步一点点12 小时前
流量从bcop网关到apisixroute,再到应用的gateway模块,再到其他服务
docker·kubernetes·gateway
MadPrinter1 天前
OpenClaw Gateway 卡死假死问题完整诊断与预防方案
gateway
RemainderTime1 天前
(十一)Spring Cloud Alibaba 2023.x:构建分布式全链路日志追踪体系
分布式·微服务·架构·gateway
qingwufeiyang_5301 天前
统一网关GateWay
linux·服务器·gateway
dgvri2 天前
Gateway Timeout504 网关超时的完美解决方法
gateway
回到原点的码农2 天前
SpringCloud Gateway 集成 Sentinel 详解 及实现动态监听Nacos规则配置实时更新流控规则
spring cloud·gateway·sentinel
小川zs3 天前
OpenClaw Gateway 频繁断开/重启问题诊断
linux·服务器·gateway
没有bug.的程序员3 天前
黑客僵尸网络的降维打击:Spring Cloud Gateway 自定义限流剿杀 Sentinel 内存黑洞
java·网络·spring·gateway·sentinel