[MM-26463] Keep query parameter for interplugin requests (#14905)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
08457860cc
Коммит
a34ea6ad63
@@ -898,6 +898,7 @@ func (api *PluginAPI) PluginHTTP(request *http.Request) *http.Response {
|
|||||||
}
|
}
|
||||||
destinationPluginId := split[1]
|
destinationPluginId := split[1]
|
||||||
newURL, err := url.Parse("/" + split[2])
|
newURL, err := url.Parse("/" + split[2])
|
||||||
|
newURL.RawQuery = request.URL.Query().Encode()
|
||||||
request.URL = newURL
|
request.URL = newURL
|
||||||
if destinationPluginId == "" || err != nil {
|
if destinationPluginId == "" || err != nil {
|
||||||
message := "No plugin specified. Form of URL should be /<pluginid>/*"
|
message := "No plugin specified. Form of URL should be /<pluginid>/*"
|
||||||
|
|||||||
@@ -1381,6 +1381,11 @@ func TestInterpluginPluginHTTP(t *testing.T) {
|
|||||||
if r.URL.Path != "/api/v2/test" {
|
if r.URL.Path != "/api/v2/test" {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.URL.Query().Get("abc") != "xyz" {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
buf := bytes.Buffer{}
|
buf := bytes.Buffer{}
|
||||||
buf.ReadFrom(r.Body)
|
buf.ReadFrom(r.Body)
|
||||||
resp := "we got:" + buf.String()
|
resp := "we got:" + buf.String()
|
||||||
@@ -1410,7 +1415,7 @@ func TestInterpluginPluginHTTP(t *testing.T) {
|
|||||||
func (p *MyPlugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) {
|
func (p *MyPlugin) MessageWillBePosted(c *plugin.Context, post *model.Post) (*model.Post, string) {
|
||||||
buf := bytes.Buffer{}
|
buf := bytes.Buffer{}
|
||||||
buf.WriteString("This is the request")
|
buf.WriteString("This is the request")
|
||||||
req, err := http.NewRequest("GET", "/testplugininterserver/api/v2/test", &buf)
|
req, err := http.NewRequest("GET", "/testplugininterserver/api/v2/test?abc=xyz", &buf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err.Error()
|
return nil, err.Error()
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user