Skip to content

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

@108825446

Description

@108825446

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<ActivityLoginUser> resultData = JsonUtils.json2Bean(responseBody , ResultData.class);
    ResultData<AuthUserVo> 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions