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。

相关推荐
利刃大大1 天前
【SpringCloud】网关GateWay && Spring Cloud Gateway && Route Predicate Factories
网关·spring·spring cloud·gateway
一个向上的运维者3 天前
基于k8s的KServe 控制平面生产级部署最佳实践:基于 Gateway API 的标准化流量管理方案
llm·gateway·istio·kserve
努力也学不会java3 天前
【Spring Cloud】统一服务入口-Gateway
后端·算法·spring·spring cloud·gateway·服务发现
dinga198510265 天前
当遇到 502 错误(Bad Gateway)怎么办
gateway
岳来5 天前
网络小白对容器参数endpoint 和gateway 对比
网络·docker·容器·gateway·endpoint
invicinble5 天前
分布式组件的全域认识和操作--gateway
分布式·gateway
阿里-于怀5 天前
Higress 已支持全新 Gateway API / Inference Extension
gateway·higress·ingress nginx
猫头虎6 天前
猫头虎AI分享:[转载]2025 年 HAMi 社区年度回顾 | 从 GPU 调度器到云原生 AI 基础设施的中流砥柱
运维·人工智能·云原生·开源·gateway·github·ai编程
文静小土豆9 天前
K8s Gateway API 全面指南:从入门到实践
kubernetes·gateway
码农垦荒笔记9 天前
OpenClaw实战#05-2:第二层工程拆解 Gateway 深度解析
人工智能·语言模型·gateway·agent·openclaw