shuaijinchao edited a comment on issue #69: URL: https://github.com/apache/apisix-go-plugin-runner/issues/69#issuecomment-1049448483
@RagavMaddali I have not reproduced the problem in my development environment. Below is my configuration: ### APISIX Route ```bash curl http://127.0.0.1:9080/apisix/admin/routes/1 -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d ' { "uri": "/go/runner", "plugins": { "ext-plugin-pre-req": { "conf": [ { "name": "say", "value":"{\"body\":\"hello\"}"} ] } }, "upstream": { "type": "roundrobin", "nodes": { "127.0.0.1:1980": 1 } } }' ``` ### Plugin ```Go func init() { err := plugin.RegisterPlugin(&Say{}) if err != nil { log.Fatalf("failed to register plugin say: %s", err) } } // Say is a demo to show how to return data directly instead of proxying // it to the upstream. type Say struct { } type SayConf struct { Body string `json:"body"` } func (p *Say) Name() string { return "say" } func (p *Say) ParseConf(in []byte) (interface{}, error) { conf := SayConf{} err := json.Unmarshal(in, &conf) return conf, err } func (p *Say) Filter(conf interface{}, w http.ResponseWriter, r pkgHTTP.Request) { body := conf.(SayConf).Body if len(body) == 0 { return } r.Header().Set("X-A6-Runner", "Go") r.Header().Set("X-A6-Hello", "World") } ``` ### Request & Response ```bash $ curl http://127.0.0.1:9080/go/runner ---Headers x-a6-runner:Go x-a6-hello:World host:127.0.0.1:9080 x-real-ip:127.0.0.1 x-forwarded-for:127.0.0.1 x-forwarded-proto:http x-forwarded-host:127.0.0.1 x-forwarded-port:9080 user-agent:curl/7.68.0 accept:*/* ---Args ---URI /go/runner ---Service Node Ubuntu-DEV-1980 ``` ### Note If you want to forward the request headers set in the Runner to the upstream, do not manipulate the `http.ResponseWriter` object, it will terminate the request. -- 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]
