Refactor InfluxDB listener (#6974)

Use streaming parser in InfluxDB listener
This commit is contained in:
reimda
2020-03-04 11:13:44 -07:00
committed by GitHub
parent ab8438dcc6
commit a0276385b1
21 changed files with 19898 additions and 18303 deletions

View File

@@ -136,7 +136,7 @@ func (h *Health) Init() error {
// Connect starts the HTTP server.
func (h *Health) Connect() error {
authHandler := internal.AuthHandler(h.BasicUsername, h.BasicPassword, onAuthError)
authHandler := internal.AuthHandler(h.BasicUsername, h.BasicPassword, "health", onAuthError)
h.server = &http.Server{
Addr: h.ServiceAddress,
@@ -168,8 +168,7 @@ func (h *Health) Connect() error {
return nil
}
func onAuthError(rw http.ResponseWriter, code int) {
http.Error(rw, http.StatusText(code), code)
func onAuthError(_ http.ResponseWriter) {
}
func (h *Health) listen() (net.Listener, error) {

View File

@@ -156,7 +156,7 @@ func (p *PrometheusClient) Init() error {
ipRange = append(ipRange, ipNet)
}
authHandler := internal.AuthHandler(p.BasicUsername, p.BasicPassword, onAuthError)
authHandler := internal.AuthHandler(p.BasicUsername, p.BasicPassword, "prometheus", onAuthError)
rangeHandler := internal.IPRangeHandler(ipRange, onError)
promHandler := promhttp.HandlerFor(registry, promhttp.HandlerOpts{ErrorHandling: promhttp.ContinueOnError})
@@ -219,9 +219,7 @@ func (p *PrometheusClient) Connect() error {
return nil
}
func onAuthError(rw http.ResponseWriter, code int) {
rw.Header().Set("WWW-Authenticate", `Basic realm="Restricted"`)
http.Error(rw, http.StatusText(code), code)
func onAuthError(_ http.ResponseWriter) {
}
func onError(rw http.ResponseWriter, code int) {