當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Context.RW方法代碼示例

本文整理匯總了Golang中github.com/wangy1931/grafana/pkg/middleware.Context.RW方法的典型用法代碼示例。如果您正苦於以下問題:Golang Context.RW方法的具體用法?Golang Context.RW怎麽用?Golang Context.RW使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/wangy1931/grafana/pkg/middleware.Context的用法示例。


在下文中一共展示了Context.RW方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: ProxyAlertDataSourceRequest

func ProxyAlertDataSourceRequest(c *middleware.Context) {
	targetUrl, _ := url.Parse(setting.Alert.AlertUrlRoot)
	director := func(req *http.Request) {
		req.URL.Scheme = targetUrl.Scheme
		req.URL.Host = targetUrl.Host
		req.Host = targetUrl.Host

		reqQueryVals := req.URL.Query()
		reqQueryVals.Add("org", strconv.FormatInt(c.OrgId, 10))
		req.URL.RawQuery = reqQueryVals.Encode()
		req.URL.Path = util.JoinUrlFragments(targetUrl.Path, "/healthsummary")
		// clear cookie headers
		req.Header.Del("Cookie")
		req.Header.Del("Set-Cookie")
	}

	proxy := &httputil.ReverseProxy{Director: director}
	proxy.Transport = dataProxyTransport
	proxy.ServeHTTP(c.RW(), c.Req.Request)
}
開發者ID:wangy1931,項目名稱:grafana,代碼行數:20,代碼來源:alert_settings.go

示例2: ProxyDataSourceRequest

func ProxyDataSourceRequest(c *middleware.Context) {
	ds, err := getDatasource(c.ParamsInt64(":id"), c.OrgId)
	if err != nil {
		c.JsonApiErr(500, "Unable to load datasource meta data", err)
		return
	}

	targetUrl, _ := url.Parse(ds.Url)
	if len(setting.DataProxyWhiteList) > 0 {
		if _, exists := setting.DataProxyWhiteList[targetUrl.Host]; !exists {
			c.JsonApiErr(403, "Data proxy hostname and ip are not included in whitelist", nil)
			return
		}
	}

	if ds.Type == m.DS_CLOUDWATCH {
		cloudwatch.HandleRequest(c, ds)
	} else {
		proxyPath := c.Params("*")
		proxy := NewReverseProxy(ds, proxyPath, targetUrl)
		proxy.Transport = dataProxyTransport
		proxy.ServeHTTP(c.RW(), c.Req.Request)
	}
}
開發者ID:wangy1931,項目名稱:grafana,代碼行數:24,代碼來源:dataproxy.go


注:本文中的github.com/wangy1931/grafana/pkg/middleware.Context.RW方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。