Render: Use https as protocol when rendering if HTTP2 enabled (#21600)

This fixes so that protocol is https instead of h2 when rendering
image if Grafana is configured to use HTTP2.

Ref grafana/grafana-image-renderer#77
This commit is contained in:
Marcus Efraimsson
2020-01-20 00:43:02 +01:00
committed by GitHub
parent b087edc224
commit d2b08c8368

View File

@@ -135,8 +135,17 @@ func (rs *RenderingService) getURL(path string) string {
return fmt.Sprintf("%s%s&render=1", rs.Cfg.RendererCallbackUrl, path)
}
protocol := setting.Protocol
switch setting.Protocol {
case setting.HTTP:
protocol = "http"
case setting.HTTP2, setting.HTTPS:
protocol = "https"
}
// &render=1 signals to the legacy redirect layer to
return fmt.Sprintf("%s://%s:%s/%s&render=1", setting.Protocol, rs.domain, setting.HttpPort, path)
return fmt.Sprintf("%s://%s:%s/%s&render=1", protocol, rs.domain, setting.HttpPort, path)
}
func (rs *RenderingService) getRenderKey(orgId, userId int64, orgRole models.RoleType) (string, error) {