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。

相关推荐
johnny2332 天前
ShenYu实战、问题记录
gateway
未来影子3 天前
Spring Ai Alibaba Gateway 实现存量应用转 MCP 工具
gateway·springai·mcp
亲爱的非洲野猪4 天前
Spring Cloud Gateway介绍 - -基础概念,简单工作原理和配置示例
java·spring boot·gateway
你喜欢喝可乐吗?6 天前
RuoYi-Cloud ruoyi-gateway 网关模块
java·spring cloud·gateway
lwb_011811 天前
SpringCloud——Gateway新一代网关
spring·spring cloud·gateway
你是人间五月天11 天前
gateway断言配置详解
gateway
weixin_3875456411 天前
深入解析 AI Gateway:新一代智能流量控制中枢
人工智能·gateway
yuluo_YX25 天前
AI Gateway 介绍
人工智能·gateway
网硕互联的小客服1 个月前
502 Bad Gateway:服务器作为网关或代理时收到无效响应处理方式
运维·服务器·gateway
sevevty-seven1 个月前
什么是Gateway
gateway