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。

相关推荐
ghostwritten5 小时前
云原生流量治理新标准:Kubernetes Gateway API 部署实践指南
云原生·kubernetes·gateway
齐 飞5 小时前
Spring Cloud Alibaba快速入门-Gateway
spring cloud·微服务·gateway
Linux运维技术栈6 小时前
Gravitee Kafka Gateway 规范部署:HTTP API化封装与安全隔离实践
http·kafka·gateway
trayvontang2 天前
Spring Gateway核心概念、流程及原理
spring·gateway·spring gateway
trayvontang2 天前
Spring Gateway常用过滤器(限流、熔断等)
spring·gateway·spring gateway·gateway常用过滤器
Hello.Reader4 天前
Flink SQL Gateway 把 Flink SQL 变成“多客户端并发可用”的统一服务入口
sql·flink·gateway
ygqygq26 天前
Kubernetes Gateway API 与 Envoy Gateway 部署使用指南
kubernetes·gateway·envoy·ingress
weixin_439706256 天前
spring boot+nacos+gateway+sentinel的简单例子
spring boot·gateway·sentinel
peihexian6 天前
ingress-nginx更换为f5 nginx gateway fabric
nginx·gateway·fabric
木子欢儿7 天前
阿里云系统磁盘总读BPS突然增长很高,导致网站502 Bad Gateway
阿里云·云计算·gateway