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 摘要。