MCPcopy
hub / github.com/koderover/zadig / New

Function New

pkg/cli/zadig-agent/util/client/client.go:96–117  ·  view source on GitHub ↗

New TODO: need to config tls security

(cfs ...ClientFunc)

Source from the content-addressed store, hash-verified

94
95// New TODO: need to config tls security
96func 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
119func (c *Client) Get(url string, rfs ...RequestFunc) (*resty.Response, error) {
120 return c.Request(resty.MethodGet, url, rfs...)

Callers 8

GetFunction · 0.70
PostFunction · 0.70
PatchFunction · 0.70
PutFunction · 0.70
DeleteFunction · 0.70
HeadFunction · 0.70
OptionsFunction · 0.70
DownloadFunction · 0.70

Calls 3

SugaredLoggerFunction · 0.92
cfFunction · 0.85
SetHeaderMethod · 0.45

Tested by

no test coverage detected