New TODO: need to config tls security
(cfs ...ClientFunc)
| 94 | |
| 95 | // New TODO: need to config tls security |
| 96 | func New(cfs ...ClientFunc) *Client { |
| 97 | r := resty.New() |
| 98 | r.SetTransport(&http.Transport{ |
| 99 | TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, |
| 100 | }) |
| 101 | r.SetHeader("Content-Type", "application/json"). |
| 102 | SetHeader("Accept", "application/json"). |
| 103 | SetHeader("User-Agent", UserAgent). |
| 104 | SetTimeout(TimeoutSeconds * time.Second). |
| 105 | SetLogger(log.SugaredLogger()) |
| 106 | |
| 107 | c := &Client{ |
| 108 | Client: r, |
| 109 | IgnoreCodes: sets.NewInt(), |
| 110 | } |
| 111 | |
| 112 | for _, cf := range cfs { |
| 113 | cf(c) |
| 114 | } |
| 115 | |
| 116 | return c |
| 117 | } |
| 118 | |
| 119 | func (c *Client) Get(url string, rfs ...RequestFunc) (*resty.Response, error) { |
| 120 | return c.Request(resty.MethodGet, url, rfs...) |