MCPcopy Create free account
hub / github.com/LumaAI-API/Luma-API / UnmarshalBodyReusable

Function UnmarshalBodyReusable

common/utils.go:154–173  ·  view source on GitHub ↗
(c *gin.Context, v any)

Source from the content-addressed store, hash-verified

152}
153
154func UnmarshalBodyReusable(c *gin.Context, v any) error {
155 requestBody, err := GetRequestBody(c)
156 if err != nil {
157 return err
158 }
159 contentType := c.Request.Header.Get("Content-Type")
160 if strings.Contains(contentType, "application/json") {
161 err = json.Unmarshal(requestBody, &v)
162 } else {
163 // skip for now
164 // try
165 err = json.Unmarshal(requestBody, &v)
166 }
167 if err != nil {
168 return err
169 }
170 // Reset request body
171 c.Request.Body = io.NopCloser(bytes.NewBuffer(requestBody))
172 return nil
173}
174
175const KeyRequestBody = "key_request_body"
176

Callers

nothing calls this directly

Calls 1

GetRequestBodyFunction · 0.85

Tested by

no test coverage detected