Spring Webflux如何获得整个请求主体?

时间:2018-10-31 01:49:15

标签: spring-webflux

我要发布请求,内容长度为817,错误获取主体大小为610,如何获取全身?需要通过参数处理动态谓词的蚂蚁!

 Flux<DataBuffer> body = exchange.getRequest().getBody();            
        AtomicReference<String> bodyRef = new AtomicReference<>();
        body.subscribe(dataBuffer -> {
            CharBuffer charBuffer = Charsets.UTF_8.decode(dataBuffer.asByteBuffer());
            DataBufferUtils.release(dataBuffer);
            bodyRef.set(charBuffer.toString());
        });

动态谓词

            routes.route(api.getMethod() + ":" + api.getVersion(), r -> r
                        .predicate(exchange -> {  
                            //params   analyzing   :     Attributes.REQUEST_PARAMETER_METHOD                   
                            ParserUtils.parseRequest(exchange);
                           //handler ...

                            return api.getMethod().equals(exchange.getAttributes().get(Attributes.REQUEST_PARAMETER_METHOD));
                        }).uri(....)

0 个答案:

没有答案