Skip to content

Commit

Permalink
Add HTTPClient interface to Pusher struct
Browse files Browse the repository at this point in the history
Signed-off-by: NghiaLT <nghialt.11@gmail.com>
  • Loading branch information
nghialt committed Apr 26, 2019
1 parent deade03 commit c9d7791
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
21 changes: 21 additions & 0 deletions prometheus/push/http.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2019 The Prometheus Authors
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package push

import "net/http"

// HTTPClient is a interface for http client
type HTTPClient interface {
Do(*http.Request) (*http.Response, error)
}
4 changes: 2 additions & 2 deletions prometheus/push/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ type Pusher struct {
gatherers prometheus.Gatherers
registerer prometheus.Registerer

client *http.Client
client HTTPClient
useBasicAuth bool
username, password string

Expand Down Expand Up @@ -170,7 +170,7 @@ func (p *Pusher) Grouping(name, value string) *Pusher {

// Client sets a custom HTTP client for the Pusher. For convenience, this method
// returns a pointer to the Pusher itself.
func (p *Pusher) Client(c *http.Client) *Pusher {
func (p *Pusher) Client(c HTTPClient) *Pusher {
p.client = c
return p
}
Expand Down

0 comments on commit c9d7791

Please sign in to comment.