...
1 package client
2
3 import "net/http"
4
5
6 func Var(name string, value interface{}) Option {
7 return func(bd *Request) {
8 if bd.Variables == nil {
9 bd.Variables = map[string]interface{}{}
10 }
11
12 bd.Variables[name] = value
13 }
14 }
15
16
17 func Operation(name string) Option {
18 return func(bd *Request) {
19 bd.OperationName = name
20 }
21 }
22
23
24 func Extensions(extensions map[string]interface{}) Option {
25 return func(bd *Request) {
26 bd.Extensions = extensions
27 }
28 }
29
30
31
32 func Path(url string) Option {
33 return func(bd *Request) {
34 bd.HTTP.URL.Path = url
35 }
36 }
37
38
39 func AddHeader(key string, value string) Option {
40 return func(bd *Request) {
41 bd.HTTP.Header.Add(key, value)
42 }
43 }
44
45
46 func BasicAuth(username, password string) Option {
47 return func(bd *Request) {
48 bd.HTTP.SetBasicAuth(username, password)
49 }
50 }
51
52
53 func AddCookie(cookie *http.Cookie) Option {
54 return func(bd *Request) {
55 bd.HTTP.AddCookie(cookie)
56 }
57 }
58
View as plain text