feat(import): import directly from grafana.net id/url now works

This commit is contained in:
Torkel Ödegaard
2016-05-27 16:11:05 +02:00
parent 22a7eaf2e7
commit c3708b3096
8 changed files with 125 additions and 36 deletions

View File

@ -5,8 +5,10 @@ import (
"net"
"net/http"
"net/http/httputil"
"net/url"
"time"
"github.com/Unknwon/log"
"github.com/grafana/grafana/pkg/middleware"
"github.com/grafana/grafana/pkg/setting"
"github.com/grafana/grafana/pkg/util"
@ -23,12 +25,15 @@ var gNetProxyTransport = &http.Transport{
}
func ReverseProxyGnetReq(proxyPath string) *httputil.ReverseProxy {
director := func(req *http.Request) {
req.URL.Scheme = "https"
req.URL.Host = "grafana.net"
req.Host = "grafana.net"
url, _ := url.Parse(setting.GrafanaNetUrl)
req.URL.Path = util.JoinUrlFragments(setting.GrafanaNetUrl+"/api", proxyPath)
director := func(req *http.Request) {
req.URL.Scheme = url.Scheme
req.URL.Host = url.Host
req.Host = url.Host
req.URL.Path = util.JoinUrlFragments(url.Path+"/api", proxyPath)
log.Info("Url: %v", req.URL.Path)
// clear cookie headers
req.Header.Del("Cookie")