File tree 2 files changed +13
-0
lines changed
2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -30,14 +30,25 @@ type client struct {
30
30
fallback cmds.Executor
31
31
}
32
32
33
+ // ClientOpt is an option that can be passed to the HTTP client constructor.
33
34
type ClientOpt func (* client )
34
35
36
+ // ClientWithUserAgent specifies the HTTP user agent for the client.
35
37
func ClientWithUserAgent (ua string ) ClientOpt {
36
38
return func (c * client ) {
37
39
c .ua = ua
38
40
}
39
41
}
40
42
43
+ // ClientWithHTTPClient specifies a custom http.Client. Defaults to
44
+ // http.DefaultClient.
45
+ func ClientWithHTTPClient (hc * http.Client ) ClientOpt {
46
+ return func (c * client ) {
47
+ c .httpClient = hc
48
+ }
49
+ }
50
+
51
+ // ClientWithAPIPrefix specifies an API URL prefix.
41
52
func ClientWithAPIPrefix (apiPrefix string ) ClientOpt {
42
53
return func (c * client ) {
43
54
c .apiPrefix = apiPrefix
@@ -53,6 +64,7 @@ func ClientWithFallback(exe cmds.Executor) ClientOpt {
53
64
}
54
65
}
55
66
67
+ // NewClient constructs a new HTTP-backed command executor.
56
68
func NewClient (address string , opts ... ClientOpt ) cmds.Executor {
57
69
if ! strings .HasPrefix (address , "http://" ) {
58
70
address = "http://" + address
Original file line number Diff line number Diff line change
1
+ package http
You can’t perform that action at this time.
0 commit comments