Skip to content

Commit

Permalink
cmd/fastly-exporter: move roundTripperFunc, userAgentTransport into m…
Browse files Browse the repository at this point in the history
…ain.go, allowing "go run cmd/fastly-exporter/main.go" (#105)
shawnps authored May 23, 2022
1 parent e0cd02b commit 396dba4
Showing 3 changed files with 11 additions and 14 deletions.
11 changes: 11 additions & 0 deletions cmd/fastly-exporter/main.go
Original file line number Diff line number Diff line change
@@ -473,3 +473,14 @@ func getLogLevel(debug bool) level.Option {
return level.AllowInfo()
}
}

type roundTripperFunc func(*http.Request) (*http.Response, error)

func (f roundTripperFunc) RoundTrip(req *http.Request) (*http.Response, error) { return f(req) }

func userAgentTransport(next http.RoundTripper, userAgent string) http.RoundTripper {
return roundTripperFunc(func(req *http.Request) (*http.Response, error) {
req.Header.Set("User-Agent", userAgent)
return next.RoundTrip(req)
})
}
File renamed without changes.
14 changes: 0 additions & 14 deletions cmd/fastly-exporter/transport.go

This file was deleted.

0 comments on commit 396dba4

Please sign in to comment.