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

Function New

pkg/tool/httpclient/client.go:96–119  ·  view source on GitHub ↗
(cfs ...ClientFunc)

Source from the content-addressed store, hash-verified

94}
95
96func New(cfs ...ClientFunc) *Client {
97 userAgent := UserAgent
98 if config.ChartVersion() != "" {
99 userAgent = fmt.Sprintf(fmt.Sprintf("%s/%s", UserAgent, config.ChartVersion()))
100 }
101
102 r := resty.New()
103 r.SetHeader("Content-Type", "application/json").
104 SetHeader("Accept", "application/json").
105 SetHeader("User-Agent", userAgent).
106 SetTimeout(TimeoutSeconds * time.Second).
107 SetLogger(log.SugaredLogger())
108
109 c := &Client{
110 Client: r,
111 IgnoreCodes: sets.NewInt(),
112 }
113
114 for _, cf := range cfs {
115 cf(c)
116 }
117
118 return c
119}
120
121func (c *Client) Get(url string, rfs ...RequestFunc) (*resty.Response, error) {
122 return c.Request(resty.MethodGet, url, rfs...)

Callers 15

NewCollieClientFunction · 0.92
InitExistedCronjobFunction · 0.92
sendDingDingMessageFunction · 0.92
sendWorkWxMessageFunction · 0.92
NewFunction · 0.92
SendMessageRequestMethod · 0.92
SendMessageRequestMethod · 0.92
NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92
NewFunction · 0.92

Calls 4

ChartVersionFunction · 0.92
SugaredLoggerFunction · 0.92
cfFunction · 0.85
SetHeaderMethod · 0.45

Tested by

no test coverage detected