MCPcopy
hub / github.com/git-lfs/git-lfs / MarshalToRequest

Function MarshalToRequest

lfsapi/body.go:16–27  ·  view source on GitHub ↗
(req *http.Request, obj interface{})

Source from the content-addressed store, hash-verified

14}
15
16func MarshalToRequest(req *http.Request, obj interface{}) error {
17 by, err := json.Marshal(obj)
18 if err != nil {
19 return err
20 }
21
22 clen := len(by)
23 req.Header.Set("Content-Length", strconv.Itoa(clen))
24 req.ContentLength = int64(clen)
25 req.Body = NewByteBody(by)
26 return nil
27}
28
29func NewByteBody(by []byte) ReadSeekCloser {
30 return &closingByteReader{Reader: bytes.NewReader(by)}

Callers 5

verifyUploadFunction · 0.92
TestDoWithAuthApproveFunction · 0.70
TestDoWithAuthRejectFunction · 0.70
TestDoWithAuthNoRetryFunction · 0.70
TestDoAPIRequestWithAuthFunction · 0.70

Calls 2

NewByteBodyFunction · 0.70
SetMethod · 0.65

Tested by 4

TestDoWithAuthApproveFunction · 0.56
TestDoWithAuthRejectFunction · 0.56
TestDoWithAuthNoRetryFunction · 0.56
TestDoAPIRequestWithAuthFunction · 0.56