本文整理汇总了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)
}
}