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。

相关推荐
WwW.-.2 天前
OpenClaw 技术解析:多渠道 AI Gateway 如何连接消息、Agent 与远程节点
网络·人工智能·gateway
@小匠2 天前
Spring-Gateway-理论知识总结/常问面试题
数据库·spring·gateway
胡斌附体2 天前
OpenClaw Gateway 代理问题排查记录
gateway·proxy·openclaw
大傻^2 天前
【OpenClaw -04】OpenClaw Gateway 架构:单一控制平面与 Agent 运行时模型
gateway·mcp·openclaw
坐吃山猪16 天前
OpenClaw04_Gateway常见问题
网络·gateway·openclaw
三水不滴16 天前
利用SpringCloud Gateway 重试 + 降级解决第三方接口频繁超时问题,提升性能
经验分享·笔记·后端·spring·spring cloud·gateway
知识即是力量ol17 天前
微服务架构:从入门到进阶完全指南
java·spring cloud·微服务·nacos·架构·gateway·feign
j2001032217 天前
Gateway—— 高级流量路由
gateway·k8s
笨蛋不要掉眼泪17 天前
Spring Cloud Gateway 核心篇:深入解析过滤器(Filter)机制与实战
java·服务器·网络·后端·微服务·gateway
笨蛋不要掉眼泪17 天前
Spring Cloud Gateway 扩展:全局跨域配置
java·分布式·微服务·架构·gateway