commit
6acbb39db0
|
|
@ -0,0 +1,28 @@
|
||||||
|
package org.dromara.gateway.config.properties;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
|
import org.springframework.cloud.context.config.annotation.RefreshScope;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* api解密属性配置类
|
||||||
|
* @author wdhcr
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Component
|
||||||
|
@RefreshScope
|
||||||
|
@ConfigurationProperties(prefix = "api-decrypt")
|
||||||
|
public class ApiDecryptProperties {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加密开关
|
||||||
|
*/
|
||||||
|
private Boolean enabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 头部标识
|
||||||
|
*/
|
||||||
|
private String headerFlag;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
package org.dromara.gateway.filter;
|
package org.dromara.gateway.filter;
|
||||||
|
|
||||||
import cn.hutool.core.map.MapUtil;
|
import cn.hutool.core.map.MapUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
import org.dromara.common.json.utils.JsonUtils;
|
import org.dromara.common.json.utils.JsonUtils;
|
||||||
|
import org.dromara.gateway.config.properties.ApiDecryptProperties;
|
||||||
import org.dromara.gateway.config.properties.CustomGatewayProperties;
|
import org.dromara.gateway.config.properties.CustomGatewayProperties;
|
||||||
import org.dromara.gateway.utils.WebFluxUtils;
|
import org.dromara.gateway.utils.WebFluxUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
@ -28,6 +30,8 @@ public class GlobalLogFilter implements GlobalFilter, Ordered {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CustomGatewayProperties customGatewayProperties;
|
private CustomGatewayProperties customGatewayProperties;
|
||||||
|
@Autowired
|
||||||
|
private ApiDecryptProperties apiDecryptProperties;
|
||||||
|
|
||||||
private static final String START_TIME = "startTime";
|
private static final String START_TIME = "startTime";
|
||||||
|
|
||||||
|
|
@ -42,8 +46,13 @@ public class GlobalLogFilter implements GlobalFilter, Ordered {
|
||||||
|
|
||||||
// 打印请求参数
|
// 打印请求参数
|
||||||
if (WebFluxUtils.isJsonRequest(exchange)) {
|
if (WebFluxUtils.isJsonRequest(exchange)) {
|
||||||
String jsonParam = WebFluxUtils.resolveBodyFromCacheRequest(exchange);
|
if (apiDecryptProperties.getEnabled()
|
||||||
log.info("[PLUS]开始请求 => URL[{}],参数类型[json],参数:[{}]", url, jsonParam);
|
&& ObjectUtil.isNotNull(request.getHeaders().getFirst(apiDecryptProperties.getHeaderFlag()))) {
|
||||||
|
log.info("[PLUS]开始请求 => URL[{}],参数类型[encrypt]", url);
|
||||||
|
} else {
|
||||||
|
String jsonParam = WebFluxUtils.resolveBodyFromCacheRequest(exchange);
|
||||||
|
log.info("[PLUS]开始请求 => URL[{}],参数类型[json],参数:[{}]", url, jsonParam);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
MultiValueMap<String, String> parameterMap = request.getQueryParams();
|
MultiValueMap<String, String> parameterMap = request.getQueryParams();
|
||||||
if (MapUtil.isNotEmpty(parameterMap)) {
|
if (MapUtil.isNotEmpty(parameterMap)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue