parent
							
								
									9d9c5ced4c
								
							
						
					
					
						commit
						5a56b5f98b
					
				| @ -1,34 +1,34 @@ | ||||
| * [首页](/?t=1565767132305) | ||||
| * [首页](/?t=1565916799573) | ||||
| * 开发文档 | ||||
|   * [快速体验](files/10010_快速体验.md?t=1565767132307) | ||||
|   * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1565767132325) | ||||
|   * [新增接口](files/10020_新增接口.md?t=1565767132325) | ||||
|   * [业务参数校验](files/10030_业务参数校验.md?t=1565767132325) | ||||
|   * [错误处理](files/10040_错误处理.md?t=1565767132325) | ||||
|   * [编写文档](files/10041_编写文档.md?t=1565767132326) | ||||
|   * [接口交互详解](files/10050_接口交互详解.md?t=1565767132326) | ||||
|   * [easyopen支持](files/10070_easyopen支持.md?t=1565767132326) | ||||
|   * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1565767132326) | ||||
|   * [ISV管理](files/10085_ISV管理.md?t=1565767132326) | ||||
|   * [自定义路由](files/10086_自定义路由.md?t=1565767132326) | ||||
|   * [自定义返回结果](files/10087_自定义返回结果.md?t=1565767132326) | ||||
|   * [自定义过滤器](files/10088_自定义过滤器.md?t=1565767132326) | ||||
|   * [路由授权](files/10090_路由授权.md?t=1565767132326) | ||||
|   * [接口限流](files/10092_接口限流.md?t=1565767132326) | ||||
|   * [监控日志](files/10093_监控日志.md?t=1565767132327) | ||||
|   * [SDK开发](files/10095_SDK开发.md?t=1565767132327) | ||||
|   * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1565767132327) | ||||
|   * [应用授权](files/10097_应用授权.md?t=1565767132327) | ||||
|   * [传统web开发](files/10100_传统web开发.md?t=1565767132327) | ||||
|   * [文件上传](files/10104_文件上传.md?t=1565767132327) | ||||
|   * [nacos注册中心](files/10106_nacos注册中心.md?t=1565767132327) | ||||
|   * [扩展其它注册中心](files/10107_扩展其它注册中心.md?t=1565767132327) | ||||
|   * [配置Sleuth链路追踪](files/10109_配置Sleuth链路追踪.md?t=1565767132327) | ||||
|   * [预发布灰度发布](files/10110_预发布灰度发布.md?t=1565767132327) | ||||
|   * [动态修改请求参数](files/10111_动态修改请求参数.md?t=1565767132327) | ||||
|   * [快速体验](files/10010_快速体验.md?t=1565916799577) | ||||
|   * [项目接入到SOP](files/10011_项目接入到SOP.md?t=1565916799596) | ||||
|   * [新增接口](files/10020_新增接口.md?t=1565916799596) | ||||
|   * [业务参数校验](files/10030_业务参数校验.md?t=1565916799596) | ||||
|   * [错误处理](files/10040_错误处理.md?t=1565916799596) | ||||
|   * [编写文档](files/10041_编写文档.md?t=1565916799596) | ||||
|   * [接口交互详解](files/10050_接口交互详解.md?t=1565916799597) | ||||
|   * [easyopen支持](files/10070_easyopen支持.md?t=1565916799597) | ||||
|   * [使用签名校验工具](files/10080_使用签名校验工具.md?t=1565916799597) | ||||
|   * [ISV管理](files/10085_ISV管理.md?t=1565916799597) | ||||
|   * [自定义路由](files/10086_自定义路由.md?t=1565916799597) | ||||
|   * [自定义返回结果](files/10087_自定义返回结果.md?t=1565916799597) | ||||
|   * [自定义过滤器](files/10088_自定义过滤器.md?t=1565916799597) | ||||
|   * [路由授权](files/10090_路由授权.md?t=1565916799598) | ||||
|   * [接口限流](files/10092_接口限流.md?t=1565916799598) | ||||
|   * [监控日志](files/10093_监控日志.md?t=1565916799598) | ||||
|   * [SDK开发](files/10095_SDK开发.md?t=1565916799598) | ||||
|   * [使用SpringCloudGateway](files/10096_使用SpringCloudGateway.md?t=1565916799598) | ||||
|   * [应用授权](files/10097_应用授权.md?t=1565916799598) | ||||
|   * [传统web开发](files/10100_传统web开发.md?t=1565916799598) | ||||
|   * [文件上传](files/10104_文件上传.md?t=1565916799598) | ||||
|   * [nacos注册中心](files/10106_nacos注册中心.md?t=1565916799599) | ||||
|   * [扩展其它注册中心](files/10107_扩展其它注册中心.md?t=1565916799599) | ||||
|   * [配置Sleuth链路追踪](files/10109_配置Sleuth链路追踪.md?t=1565916799599) | ||||
|   * [预发布灰度发布](files/10110_预发布灰度发布.md?t=1565916799599) | ||||
|   * [动态修改请求参数](files/10111_动态修改请求参数.md?t=1565916799599) | ||||
| * 原理分析 | ||||
|   * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1565767132328) | ||||
|   * [原理分析之路由存储](files/90011_原理分析之路由存储.md?t=1565767132328) | ||||
|   * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1565767132328) | ||||
|   * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1565767132328) | ||||
|   * [常见问题](files/90100_常见问题.md?t=1565767132328) | ||||
|   * [原理分析之@ApiMapping](files/90010_原理分析之@ApiMapping.md?t=1565916799599) | ||||
|   * [原理分析之路由存储](files/90011_原理分析之路由存储.md?t=1565916799599) | ||||
|   * [原理分析之如何路由](files/90012_原理分析之如何路由.md?t=1565916799599) | ||||
|   * [原理分析之文档归纳](files/90013_原理分析之文档归纳.md?t=1565916799600) | ||||
|   * [常见问题](files/90100_常见问题.md?t=1565916799600) | ||||
|  | ||||
| @ -0,0 +1,41 @@ | ||||
| package com.gitee.sop.gatewaycommon.gateway.filter; | ||||
| 
 | ||||
| import com.gitee.sop.gatewaycommon.gateway.ServerWebExchangeUtil; | ||||
| import com.gitee.sop.gatewaycommon.param.ApiParam; | ||||
| import com.gitee.sop.gatewaycommon.param.ParamNames; | ||||
| import com.gitee.sop.gatewaycommon.param.ParameterFormatter; | ||||
| import com.gitee.sop.gatewaycommon.zuul.ZuulContext; | ||||
| import lombok.extern.slf4j.Slf4j; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.cloud.gateway.filter.GatewayFilterChain; | ||||
| import org.springframework.cloud.gateway.filter.GlobalFilter; | ||||
| import org.springframework.core.Ordered; | ||||
| import org.springframework.web.server.ServerWebExchange; | ||||
| import reactor.core.publisher.Mono; | ||||
| 
 | ||||
| /** | ||||
|  * @author tanghc | ||||
|  */ | ||||
| @Slf4j | ||||
| public class ParameterFormatterFilter implements GlobalFilter, Ordered { | ||||
| 
 | ||||
|     @Autowired(required = false) | ||||
|     private ParameterFormatter sopParameterFormatter; | ||||
| 
 | ||||
|     @Override | ||||
|     public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) { | ||||
|         ApiParam apiParam = ZuulContext.getApiParam(); | ||||
|         // 校验成功后进行参数转换
 | ||||
|         if (sopParameterFormatter != null) { | ||||
|             ServerWebExchange formatExchange = ServerWebExchangeUtil.format(exchange, apiParam, sopParameterFormatter::format); | ||||
|             ServerWebExchange serverWebExchange = ServerWebExchangeUtil.addHeaders(formatExchange, httpHeaders -> httpHeaders.add(ParamNames.HEADER_VERSION_NAME, apiParam.fetchVersion())); | ||||
|             return chain.filter(serverWebExchange); | ||||
|         } | ||||
|         return chain.filter(exchange); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public int getOrder() { | ||||
|         return 0; | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,10 @@ | ||||
| package com.gitee.sop.gatewaycommon.param; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import com.gitee.sop.gatewaycommon.manager.Formatter; | ||||
| 
 | ||||
| /** | ||||
|  * @author tanghc | ||||
|  */ | ||||
| public interface ParameterFormatter extends Formatter<JSONObject> { | ||||
| } | ||||
| @ -1,10 +0,0 @@ | ||||
| package com.gitee.sop.gatewaycommon.zuul.param; | ||||
| 
 | ||||
| import com.alibaba.fastjson.JSONObject; | ||||
| import com.gitee.sop.gatewaycommon.manager.ParameterFormatter; | ||||
| 
 | ||||
| /** | ||||
|  * @author tanghc | ||||
|  */ | ||||
| public interface ZuulParameterFormatter extends ParameterFormatter<JSONObject> { | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue