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。

相关推荐
yxl874646463 天前
磐创PCTG-9013 Modbus转ProfibusDP工业协议转换器
网络·科技·物联网·gateway·信息与通信
__log3 天前
401鉴权问题完全指南:从“门卫拦人“到“畅通无阻“
gateway
暗夜猎手-大魔王4 天前
hermes源码学习8--Gateway 内部机制
人工智能·gateway
JJJennie7776 天前
从苹果 2026 落地场景,看系统级 Agent 时代的隐私边界与 MAI Gateway 的企业Token治理
人工智能·gateway·apple
kakawzw6 天前
微服务组件源码6——Spring Gateway
spring·gateway
白露与泡影6 天前
Java 8老系统旁路接入AI Gateway:不升级JDK也能用AI
java·人工智能·gateway
是一个Bug7 天前
Nginx 与 API Gateway:从“小区门卫”到“商场总服务台”
运维·nginx·gateway
大G的笔记本7 天前
生产级 Spring Boot 网关完整实现方案
java·笔记·gateway
暗夜猎手-大魔王9 天前
转载--Hermes Agent 13 | Gateway 架构:二十余渠道如何复用同一套 Agent Runtime
人工智能·gateway
YJlio10 天前
OpenClaw 2026.5.2 Beta 更新解读:外部插件安装、ClawHub / npm 切换与 Gateway 性能优化
性能优化·npm·gateway·飞书·多维表格·飞书aily·飞书妙搭