MCPcopy
hub / github.com/larksuite/cli / buildStreamBody

Function buildStreamBody

internal/client/client.go:293–310  ·  view source on GitHub ↗
(body interface{})

Source from the content-addressed store, hash-verified

291}
292
293func buildStreamBody(body interface{}) (io.Reader, string, error) {
294 switch typed := body.(type) {
295 case nil:
296 return nil, "", nil
297 case io.Reader:
298 return typed, "", nil
299 case []byte:
300 return bytes.NewReader(typed), "", nil
301 case string:
302 return strings.NewReader(typed), "text/plain; charset=utf-8", nil
303 default:
304 payload, err := json.Marshal(typed)
305 if err != nil {
306 return nil, "", errs.NewInternalError(errs.SubtypeSDKError, "failed to encode request body: %s", err).WithCause(err)
307 }
308 return bytes.NewReader(payload), "application/json", nil
309 }
310}
311
312// DoAPI executes a raw Lark SDK request and returns the raw *larkcore.ApiResp.
313// Unlike CallAPI which always JSON-decodes, DoAPI returns the raw response — suitable

Callers 1

DoStreamMethod · 0.85

Calls 2

NewInternalErrorFunction · 0.92
WithCauseMethod · 0.45

Tested by

no test coverage detected