| Total Lines | 21 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | package scan |
||
| 2 | |||
| 3 | import "net/http" |
||
| 4 | |||
| 5 | type Doer interface { |
||
|
|
|||
| 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 |