The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/pkg/registry/apis/datasource/sub_proxy.go

48 lines
1.1 KiB

package datasource
import (
"context"
"fmt"
"net/http"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/rest"
"github.com/grafana/grafana/pkg/plugins"
)
type subProxyREST struct {
pluginJSON plugins.JSONData
}
var _ = rest.Connecter(&subProxyREST{})
func (r *subProxyREST) New() runtime.Object {
return &metav1.Status{}
}
func (r *subProxyREST) Destroy() {}
func (r *subProxyREST) ConnectMethods() []string {
unique := map[string]bool{}
methods := []string{}
for _, r := range r.pluginJSON.Routes {
if unique[r.Method] {
continue
}
unique[r.Method] = true
methods = append(methods, r.Method)
}
return methods
}
func (r *subProxyREST) NewConnectOptions() (runtime.Object, bool, string) {
return nil, true, ""
}
func (r *subProxyREST) Connect(ctx context.Context, name string, opts runtime.Object, responder rest.Responder) (http.Handler, error) {
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
responder.Error(fmt.Errorf("TODO, proxy: %s", r.pluginJSON.ID))
}), nil
}