RequestBodyPlugin can be extended multi times

This commit is contained in:
hongqiaowei
2021-10-15 15:27:42 +08:00
parent 1cde4eb478
commit 6a284f5528
2 changed files with 5 additions and 3 deletions

View File

@@ -231,7 +231,7 @@ public class PathMapping {
obj = cast(obj, type, path);
}
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
throw new FizzRuntimeException(String.format("path mapping errer: %s , path mapping data: %s %s", e.getMessage(), type, path), e);
}
}
@@ -298,7 +298,7 @@ public class PathMapping {
}
return obj;
} catch (Exception e) {
e.printStackTrace();
// e.printStackTrace();
throw new FizzRuntimeException(String.format("failed to cast %s to %s, JSON path expression: %s, error: %s", obj, type, path, e.getMessage()), e);
}
}

View File

@@ -37,7 +37,6 @@ import java.util.Map;
/**
* Your plugin P can extend this class and override the doFilter method, then you can modify the request later.
* warn: P and @Component(RequestBodyPlugin.REQUEST_BODY_PLUGIN) can't be applied at the same time.
*
* @author hongqiaowei
*/
@@ -53,6 +52,9 @@ public class RequestBodyPlugin implements FizzPluginFilter {
public Mono<Void> filter(ServerWebExchange exchange, Map<String, Object> config) {
ServerHttpRequest req = exchange.getRequest();
if (req instanceof FizzServerHttpRequestDecorator) {
return doFilter(exchange, config);
}
return
NettyDataBufferUtils.join(req.getBody()).defaultIfEmpty(NettyDataBufferUtils.EMPTY_DATA_BUFFER)
.flatMap(