apache / apache/apisix-go-plugin-runner

request help: How to get pkgHTTP.Request in ResponseFilter?

Open
#153 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
198
Forks
68
PR merge metrics
No merged PRs in 30d

Description

### Issue description

I am trying to get pkgHTTP.Request in ResponseFilter method. I have modified the `HTTPRespCall` method in `apisix-go-plugin-runner/internal/plugin/plugin.go` as follows:

```go
func HTTPRespCall(buf []byte, conn net.Conn) (*flatbuffers.Builder, error) {
+ req := inHTTP.CreateRequest(buf)
+ req.BindConn(conn)
+ defer inHTTP.ReuseRequest(req)

resp := inHTTP.CreateResponse(buf)
resp.BindConn(conn)
defer inHTTP.ReuseResponse(resp)

token := resp.ConfToken()
conf, err := GetRuleConf(token)
if err != nil {
return nil, err
}

+ err = ResponsePhase.filter(conf, resp, req)

// ....
}
```
But I found that all the properties I received was empty. How should I handle it?

```bash
request: &{r:0xc0003ea860 conn:0xc0000122d8 extraInfoHeader:[] path:[] hdr:0xc0000122e8 rawHdr:map[] args:map[] rawArgs:map[] vars:map[] body:[] ctx:0xc00049d5c0 cancel:0x531ae0 respHdr:map[]}%!(EXTRA http.Header=map[])
```

If this modification is completed, I am willing to submit a PR.

### Environment

* APISIX Go Plugin Runner's version: latest
* APISIX version: 3.6.0
* Go version: 1.19.4
* OS (cmd: `uname -a`): debian

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.