Passed
Pull Request — master (#30)
by Stefano
02:32
created

pkg/scan/doer.go   A

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 12
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A scan.newUserAgentDoerDecorator 0 2 1
A scan.*userAgentDoerDecorator.Do 0 4 1
1
package scan
2
3
import "net/http"
4
5
type Doer interface {
0 ignored issues
show
introduced by
exported type Doer should have comment or be unexported
Loading history...
6
	Do(*http.Request) (*http.Response, error)
7
}
8
9
func newUserAgentDoerDecorator(doer Doer, userAgent string) *userAgentDoerDecorator {
10
	return &userAgentDoerDecorator{doer: doer, userAgent: userAgent}
11
}
12
13
type userAgentDoerDecorator struct {
14
	doer      Doer
15
	userAgent string
16
}
17
18
func (u *userAgentDoerDecorator) Do(r *http.Request) (*http.Response, error) {
19
	r.Header.Set("User-Agent", u.userAgent)
20
21
	return u.doer.Do(r)
22
}
23