mirror of https://github.com/grafana/grafana.git
				
				
				
			DS apiserver: Minor fixes (#84691)
This commit is contained in:
		
							parent
							
								
									58170d4141
								
							
						
					
					
						commit
						e978d0810e
					
				|  | @ -69,6 +69,7 @@ func (r *subQueryREST) Connect(ctx context.Context, name string, opts runtime.Ob | ||||||
| 		} | 		} | ||||||
| 		if dsRef != nil && dsRef.UID != name { | 		if dsRef != nil && dsRef.UID != name { | ||||||
| 			responder.Error(fmt.Errorf("expected query body datasource and request to match")) | 			responder.Error(fmt.Errorf("expected query body datasource and request to match")) | ||||||
|  | 			return | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		ctx = backend.WithGrafanaConfig(ctx, pluginCtx.GrafanaConfig) | 		ctx = backend.WithGrafanaConfig(ctx, pluginCtx.GrafanaConfig) | ||||||
|  |  | ||||||
|  | @ -5,6 +5,7 @@ import ( | ||||||
| 	"fmt" | 	"fmt" | ||||||
| 	"io" | 	"io" | ||||||
| 	"net/http" | 	"net/http" | ||||||
|  | 	"net/url" | ||||||
| 	"strings" | 	"strings" | ||||||
| 
 | 
 | ||||||
| 	"github.com/grafana/grafana-plugin-sdk-go/backend" | 	"github.com/grafana/grafana-plugin-sdk-go/backend" | ||||||
|  | @ -66,12 +67,21 @@ func (r *subResourceREST) Connect(ctx context.Context, name string, opts runtime | ||||||
| 			return | 			return | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		path := req.URL.Path[idx+len("/resource"):] | 		clonedReq := req.Clone(req.Context()) | ||||||
|  | 		rawURL := req.URL.Path[idx+len("/resource"):] | ||||||
|  | 
 | ||||||
|  | 		clonedReq.URL = &url.URL{ | ||||||
|  | 			Path:     rawURL, | ||||||
|  | 			RawQuery: clonedReq.URL.RawQuery, | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
| 		err = r.builder.client.CallResource(ctx, &backend.CallResourceRequest{ | 		err = r.builder.client.CallResource(ctx, &backend.CallResourceRequest{ | ||||||
| 			PluginContext: pluginCtx, | 			PluginContext: pluginCtx, | ||||||
| 			Path:          path, | 			Path:          clonedReq.URL.Path, | ||||||
| 			Method:        req.Method, | 			Method:        req.Method, | ||||||
|  | 			URL:           req.URL.String(), | ||||||
| 			Body:          body, | 			Body:          body, | ||||||
|  | 			Headers:       req.Header, | ||||||
| 		}, httpresponsesender.New(w)) | 		}, httpresponsesender.New(w)) | ||||||
| 
 | 
 | ||||||
| 		if err != nil { | 		if err != nil { | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue