ZhangShangyu opened a new issue, #9997:
URL: https://github.com/apache/apisix/issues/9997

   ### Current Behavior
   
   We have implement a Golang plugin to rewrite the request path, after rewrite 
the path the original args(query string) are dropped, it is not our expected 
behavior
   
   1. the Golang plugin example:
   
   ```go
   func (a *Auth) RequestFilter(conf interface{}, w http.ResponseWriter, r 
pkgHTTP.Request) {
        newPath := string(r.Path()) + "/v2"
        r.SetPath([]byte(newPath))
   }
   ```
   
   2. enable the ext-plugin-post-req and do request with query string, result 
is unexpected
   ```
   curl localhost:9080/test?a=1
   get access log in upstream backend:  {"query": ""}
   ```
   
   3. disable the ext-plugin-post-req and do request with query string, result 
is expected
   ```
   curl localhost:9080/test?a=1
   get access log in upstream backend:  {"query": "a=1"}
   ```
   
   
   ### Expected Behavior
   
   I checked the ext-plugin source code
   
https://github.com/apache/apisix/blob/master/apisix/plugins/ext-plugin/init.lua#L642
   it will set path as upstream_uri, even if there are query strings will not 
be added
   
   it can be fixed it by add these code, i retry do request and there are query 
string in upstream log
   ```lua
   if var.args then
       var.upstream_uri = path .. '?' .. var.args
   end
   ```
   
   
   ### Error Logs
   
   _No response_
   
   ### Steps to Reproduce
   
   1. implement a Go plugin to rewrite path
   2. do request with query string
   
   ### Environment
   
   - APISIX version (run `apisix version`): 2.15.3
   


-- 
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