zoukankan      html  css  js  c++  java
  • 处理webflux 项目 增加 content-path

    需求: 增加路由前缀
    项目: 基于webflux 的 r2dbc 建立的 mqtt项目

    解决方案: 一

    # springboot 项目
    # 版本 >=2.3.release
    spring:
      webflux:
        base-path: "/project-name"
    
    

    解决方案: 二

    server:
      servlet:
        context-path: "/project-name"
    
    @Bean
    public WebFilter contextPathWebFilter() {
        String contextPath = serverProperties.getServlet().getContextPath();
        return (exchange, chain) -> {
            ServerHttpRequest request = exchange.getRequest();
            if (request.getURI().getPath().startsWith(contextPath)) {
                return chain.filter(
                    exchange.mutate()
                    .request(request.mutate().contextPath(contextPath).build())
                    .build());
            }
            return chain.filter(exchange);
        };
    }
    
  • 相关阅读:
    oracle学习6
    oracle学习5
    oracle学习4
    oracle学习3
    oracle的过滤与排序
    poj1064 Cable master
    poj3169 Layout
    UVA
    poj2341 Expedition
    poj3617 Best Cow Line
  • 原文地址:https://www.cnblogs.com/akashicbrother/p/14744846.html
Copyright © 2011-2022 走看看