MCPcopy Index your code
hub / github.com/go-dev-frame/sponge / SetBody

Method SetBody

pkg/httpcli/httpcli.go:90–100  ·  view source on GitHub ↗

SetBody set body data, support string and []byte, if it is not string, it will be json marshal.

(body interface{})

Source from the content-addressed store, hash-verified

88
89// SetBody set body data, support string and []byte, if it is not string, it will be json marshal.
90func (req *Request) SetBody(body interface{}) *Request {
91 switch v := body.(type) {
92 case string:
93 req.body = v
94 case []byte:
95 req.body = string(v)
96 default:
97 req.bodyJSON = body
98 }
99 return req
100}
101
102// SetTimeout set timeout
103func (req *Request) SetTimeout(t time.Duration) *Request {

Callers 6

DoMethod · 0.95
doFunction · 0.95
TestPostStandardFunction · 0.80
TestPutStandardFunction · 0.80
TestPatchStandardFunction · 0.80
TestErrorFunction · 0.80

Calls

no outgoing calls

Tested by 4

TestPostStandardFunction · 0.64
TestPutStandardFunction · 0.64
TestPatchStandardFunction · 0.64
TestErrorFunction · 0.64