Refactor InfluxDB listener (#6974)
Use streaming parser in InfluxDB listener
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user