We are using go custom plugin but it is giving 500 error
http: superfluous response.WriteHeader call from github.com/TykTechnologies/tyk/gateway.(*ReverseProxy).HandleResponse (reverse_proxy.go:1382)
But it is working fine locally using docker we have tyk 5.3.1 and using bundles
import (
"bytes"
"io/ioutil"
"net/http"
)
// MyPluginResponse intercepts response from upstream
func MyPluginResponse(rw http.ResponseWriter, res *http.Response, req *http.Request) {
// add a header to our response object
//res.Header.Add("X-Response-Added", "resp-added")
rw.WriteHeader(http.StatusOK)
// overwrite our response body
var buf bytes.Buffer
buf.Write([]byte(`{"message":"Hi! I'm a response plugin"}`))
res.Body = ioutil.NopCloser(&buf)
}
func main() {}
{
"custom_middleware": {
"response": [
{
"name": "MyPluginResponse",
"require_session": false,
"raw_body_only": false,
"path": "MyPluginResponse.so"
}
],
"driver": "goplugin"
},
"file_list": [
"MyPluginResponse_v5.3.1_linux_amd64.so"
]
}
Thanks,
Shahbaz Ali