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

scan.newUserAgentDoerDecorator   A

Complexity

Conditions 1

Size

Total Lines 2
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nop 2
dl 0
loc 2
rs 10
c 0
b 0
f 0
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