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。

相关推荐
zx2859634001 天前
Laravel5.x版本革新特性全解析
mysql·gateway·智能路由器
nvd112 天前
企业级全场景 API 网关实践:基于 Kong Hybrid 模式的跨 VPC 部署与 GitOps 治理
gateway·kong
nvd112 天前
深度解析:Kong Hybrid 模式与 KIC (Gateway API) 架构演进与核心异同
架构·gateway·kong
zx2859634002 天前
Laravel10.x重磅升级:核心特性全解析
mysql·gateway·智能路由器
暗夜猎手-大魔王3 天前
转载--AI Agent 架构设计:Gateway 架构设计(OpenClaw、Claude Code、Hermes Agent 对比)
gateway
SarL EMEN3 天前
Gateway Timeout504 网关超时的完美解决方法
gateway
2601_949194264 天前
Gateway Timeout504 网关超时的完美解决方法
gateway
码点滴5 天前
私有 Gateway 接入企业 IM:从消息路由到多租户隔离——Hermes Agent 工程实战
人工智能·架构·gateway·prompt·智能体·hermes
代码写到35岁5 天前
Gateway+OpenFeign 踩坑总结
gateway
invicinble5 天前
对于gateway信息量沉淀
gateway