🎨 改进结构和代码格式。 代码格式调整机器 验证码返回content-type 修改
This commit is contained in:
1 parent
bfa08e6166
commit
f0cce97d3a
2 files changed
+3
-1
No files matched your search
+1
-1
@@ -59,7 +59,7 @@ public class PigxRequestGlobalFilter implements GlobalFilter, Ordered {
|
||||
public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
|
||||
// 1. 清洗请求头中from 参数
|
||||
ServerHttpRequest request = exchange.getRequest().mutate()
|
||||
.headers(httpHeaders -> {httpHeaders.remove(SecurityConstants.FROM);})
|
||||
.headers(httpHeaders -> httpHeaders.remove(SecurityConstants.FROM))
|
||||
.build();
|
||||
|
||||
// 2. 重写StripPrefix
|
||||
|
||||
+2
@@ -35,6 +35,7 @@ import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFac
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.server.reactive.ServerHttpRequest;
|
||||
import org.springframework.http.server.reactive.ServerHttpResponse;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -92,6 +93,7 @@ public class ValidateCodeGatewayFilter extends AbstractGatewayFilterFactory {
|
||||
checkCode(request);
|
||||
} catch (Exception e) {
|
||||
ServerHttpResponse response = exchange.getResponse();
|
||||
response.getHeaders().setContentType(MediaType.APPLICATION_JSON_UTF8);
|
||||
response.setStatusCode(HttpStatus.PRECONDITION_REQUIRED);
|
||||
try {
|
||||
return response.writeWith(Mono.just(response.bufferFactory()
|
||||
|
||||
Reference in new issue
Block a user