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。

相关推荐
疯狂的维修2 天前
关于Gateway configration studio软件配置网关
网络协议·c#·自动化·gateway
hadage2332 天前
--- 统一请求入口 Gateway ---
gateway
波波烤鸭4 天前
深入理解 Gateway 网关:原理、源码解析与最佳实践
java·spring·gateway
DO_Community4 天前
DigitalOcean Kubernetes 现已支持 Gateway API 托管服务
容器·kubernetes·gateway
T_Ghost4 天前
SpringCloud微服务网关Gateway
spring cloud·微服务·gateway
Rysxt_6 天前
Spring Boot Gateway 教程:从入门到精通
spring boot·网关·gateway
月夕·花晨6 天前
Gateway -网关
java·服务器·分布式·后端·spring cloud·微服务·gateway
sanggou6 天前
License 集成 Spring Gateway:解决 WebFlux 非阻塞与 Spring MVC Servlet 阻塞兼容问题
spring·gateway·mvc
摘星编程12 天前
Nginx 502 Bad Gateway:从 upstream 日志到 FastCGI 超时复盘
网络·nginx·gateway·php-fpm·fastcgi
网硕互联的小客服12 天前
504 Gateway Timeout:服务器作为网关或代理时未能及时获得响应如何处理?
运维·服务器·gateway