File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1089,6 +1089,7 @@ type apiOptions struct {
1089
1089
lookbackDelta time.Duration
1090
1090
stats StatsValue
1091
1091
limit uint64
1092
+ customOptions map [string ]string
1092
1093
}
1093
1094
1094
1095
type Option func (c * apiOptions )
@@ -1127,6 +1128,16 @@ func WithLimit(limit uint64) Option {
1127
1128
}
1128
1129
}
1129
1130
1131
+ // WithCustomOption sets an arbitrary key/value pair on the API request.
1132
+ func WithCustomOption (key , value string ) Option {
1133
+ return func (c * apiOptions ) {
1134
+ if c .customOptions == nil {
1135
+ c .customOptions = make (map [string ]string )
1136
+ }
1137
+ c .customOptions [key ] = value
1138
+ }
1139
+ }
1140
+
1130
1141
func addOptionalURLParams (q url.Values , opts []Option ) url.Values {
1131
1142
opt := & apiOptions {}
1132
1143
for _ , o := range opts {
@@ -1149,6 +1160,15 @@ func addOptionalURLParams(q url.Values, opts []Option) url.Values {
1149
1160
q .Set ("limit" , strconv .FormatUint (opt .limit , 10 ))
1150
1161
}
1151
1162
1163
+ if opt .customOptions != nil {
1164
+ for k , v := range opt .customOptions {
1165
+ if k == "" || v == "" {
1166
+ continue
1167
+ }
1168
+ q .Set (k , v )
1169
+ }
1170
+ }
1171
+
1152
1172
return q
1153
1173
}
1154
1174
You can’t perform that action at this time.
0 commit comments