apache / apache/apisix-java-plugin-runner

request help: i want to rewrite the response and then return to the client

未关闭
#232 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
Java
星标
152
派生
102
PR 合并指标
30 天内没有已合并 PR

描述

### Issue description
I want to get the upstream response content in the plugin for processing and then return to the client, but it return null
This is how the class is handled:
@Override
public void postFilter(PostRequest request, PostResponse response, PluginFilterChain chain) {
log.warn("ClientAuthenticationFilter is running");

log.warn("status:{}", request.getUpstreamStatusCode());
// get the upstream response body
String responseBody = request.getBody();
ResultData resultData = JsonUtils.json2Bean(responseBody , ResultData.class);
ResultData authResult = new ResultData<>();
authResult.setCode(resultData.getCode());
authResult.setMessage(resultData.getMessage());
if(ObjectUtils.isNotEmpty(resultData.getData())){
AuthUserVo authUserVo = processAuthResult(resultData.getData());
authResult.setData(authUserVo);
}
response.setBody(JsonUtils.bean2Json(authResult));
chain.postFilter(request, response);
}

java.lang.NullPointerException: null
postFilter(ClientAuthenticationFilter.java:85)
### Environment

* your apisix-java-plugin-runner version 0.4.0

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。