本文整理匯總了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)
}
示例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)
}
}