import (
"bytes"
- "context"
"encoding/json"
"fmt"
"io/ioutil"
rc := multiClusterQueryResponseCollector{clusterID: clusterID}
var resp *http.Response
- var cancel context.CancelFunc
if clusterID == h.handler.Cluster.ClusterID {
- resp, cancel, err = h.handler.localClusterRequest(&remoteReq)
+ resp, err = h.handler.localClusterRequest(&remoteReq)
} else {
- resp, cancel, err = h.handler.remoteClusterRequest(clusterID, &remoteReq)
+ resp, err = h.handler.remoteClusterRequest(clusterID, &remoteReq)
}
rc.collectResponse(resp, err)
- if cancel != nil {
- cancel()
- }
if rc.error != nil {
return nil, "", rc.error
if op == "in" {
if rhs, ok := filter[2].([]interface{}); ok {
for _, i := range rhs {
- if u, ok := i.(string); ok {
+ if u, ok := i.(string); ok && len(u) == 27 {
*clusterId = u[0:5]
queryClusters[u[0:5]] = append(queryClusters[u[0:5]], u)
expectCount += 1
}
}
} else if op == "=" {
- if u, ok := filter[2].(string); ok {
+ if u, ok := filter[2].(string); ok && len(u) == 27 {
*clusterId = u[0:5]
queryClusters[u[0:5]] = append(queryClusters[u[0:5]], u)
expectCount += 1
return
}
+ var uuid string
+ if len(m[1]) > 0 {
+ // trim leading slash
+ uuid = m[1][1:]
+ }
for _, d := range h.delegates {
- if d(h, effectiveMethod, &clusterId, m[1], m[3], w, req) {
+ if d(h, effectiveMethod, &clusterId, uuid, m[3], w, req) {
return
}
}
if clusterId == "" || clusterId == h.handler.Cluster.ClusterID {
h.next.ServeHTTP(w, req)
} else {
- resp, cancel, err := h.handler.remoteClusterRequest(clusterId, req)
- if cancel != nil {
- defer cancel()
- }
+ resp, err := h.handler.remoteClusterRequest(clusterId, req)
h.handler.proxy.ForwardResponse(w, resp, err)
}
}