GitHub user painAdmin created a discussion: [General][Java SDK (Component)] 
Dubbo3 使用tri协议如何在filter中打印jsonbody

### Pre-check

- [X] I am sure that all the content I provide is in English.


### Apache Dubbo Component

Java SDK (apache/dubbo)

### Details

背景:
1.项目使用springboot+dubbo3,搭建工程,接受处理Post+json的请求,定义的controller如下:
ps:The project uses springboot+dubbo3 to build a project, accept and process 
Post+json requests, and the controller is defined as follows:

/**
     * test
     *
     * @return
     */
    @PostMapping("/api/test.go")
    @Override
    public Response<JSONObject>  testMethod(HttpServletRequest request) {
         xxxxxxxx;
}

3.filter定义如下:
public class DubboServeFilter implements Filter {

    @Override
    public Result invoke(Invoker<?> invoker, Invocation invocation) throws 
RpcException {
            xxxxxx
}

需求问题:想在filter中统一打印请求的 body数据,如果通过下面stream获取,则controller中获取不到body数据,请问改如何获取数据
ps:Requirement question: I want to print the body data of the request uniformly 
in the filter. If I get it through the following stream, the body data cannot 
be obtained in the controller. How can I get the data instead?

String jsonBody = new BufferedReader(request.getReader())
                    .lines()
                    .collect(Collectors.joining());
            return JSONObject.parseObject(jsonBody);


### Code of Conduct

- [X] I agree to follow this project's [Code of 
Conduct](https://www.apache.org/foundation/policies/conduct)


GitHub link: https://github.com/apache/dubbo/discussions/15688

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to