使用本机反应堆netty,在采用exectue方法后如何更改响应状态?

时间:2019-02-24 09:26:10

标签: post reactor-netty

我使用Reactor-netty执行一个发布请求 代码是这个

(req, resp) -> resp.addHeader(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.APPLICATION_JSON)
            .status(HttpResponseStatus.OK)
            .sendString(req
                .receive()
                .map(byteBuf -> {
                    CommonResponse<Object> response;
                    try {
                        response = (CommonResponse<Object>) method.invoke(handleObject, getMethodParams(method, req, resp, byteBuf));
                    } catch (Exception e) {
                        response = exceptionPublisher(e);
                        // in here i need get the code to change response status
                        int errorCode = response.getErr_code();
                        ...?
                    }
                    return response;
                })
                .map(gsonCreate::toJson)
            );

但是,execute方法可能会引发自定义错误 并且我需要这种观念s error code to chanage the response status , now I can不要这样做,该怎么办?谢谢

0 个答案:

没有答案