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。

相关推荐
shamalee2 天前
Nginx反向代理出现502 Bad Gateway问题的解决方案
运维·nginx·gateway
xiaolingting2 天前
Gateway 网关流控与限流架构指南
spring cloud·架构·gateway·sentinel
无级程序员2 天前
k8s v1.35配置gateway, istio通过metalb vip访问
kubernetes·gateway·istio
江畔何人初3 天前
Gateway API 的核心组件与作用
运维·网络·云原生·kubernetes·gateway
zklgin3 天前
Gateway Timeout504 网关超时的完美解决方法
gateway
WwW.-.5 天前
OpenClaw 技术解析:多渠道 AI Gateway 如何连接消息、Agent 与远程节点
网络·人工智能·gateway
@小匠5 天前
Spring-Gateway-理论知识总结/常问面试题
数据库·spring·gateway
胡斌附体5 天前
OpenClaw Gateway 代理问题排查记录
gateway·proxy·openclaw
大傻^5 天前
【OpenClaw -04】OpenClaw Gateway 架构:单一控制平面与 Agent 运行时模型
gateway·mcp·openclaw
坐吃山猪19 天前
OpenClaw04_Gateway常见问题
网络·gateway·openclaw