thinkdb1 commented on issue #127:
URL: 
https://github.com/apache/apisix-go-plugin-runner/issues/127#issuecomment-1786557078

   我试着修改了几个文件,发现可以修改request body值了,先发你先参考看看
   
   apisix-core-with-plugin/internal/http/request.go中
   1.加入
   ```
   func (r *Request) SetBody(b []byte) {
        r.body = b
   }
   ```
   2.在(r *Request) FetchChanges(id uint32, builder *flatbuffers.Builder)中把
   ```
   if r.path == nil && r.hdr == nil && r.args == nil && r.respHdr == nil {
                return false
        }
   ```
   改为
   ```
   if r.path == nil && r.hdr == nil && r.args == nil && r.respHdr == nil && 
r.body == nil {
                return false
        }
   ```
   3.在(r *Request) FetchChanges(id uint32, builder *flatbuffers.Builder)中在
   ```
   if r.path != nil {
                path = builder.CreateByteString(r.path)
        }
   ```
   后加入
   ```
   if r.body != nil {
                body = builder.CreateByteString(r.body)
        }
   ```
   4.在(r *Request) FetchChanges(id uint32, builder *flatbuffers.Builder)中把
   ```
   var path flatbuffers.UOffsetT
   ```
   改为
   ```
   var path, body flatbuffers.UOffsetT
   ```
   
   5.在(r *Request) FetchChanges(id uint32, builder *flatbuffers.Builder)中在
   ```
   if path > 0 {
                hrc.RewriteAddPath(builder, path)
        }
   ```
   后加入
   ```
   if body > 0 {
                hrc.RewriteAddBody(builder, body)
        }
   ```
   
   6.在apisix-core-with-plugin/pkg/http/http.go中的Request interface加入
   SetBody([]byte)
   7.在go.mod中github.com/api7/ext-plugin-proto改为v0.6.1
   
   
   
在使用时使用r.SetBody([]byte("mytestbody"))并且在apisix的3.6.0版本下使用就可以了,我只是试用成功了,没测试是否还有其他问题
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to