MCPcopy
hub / github.com/danielgtaylor/huma / Unmarshal

Method Unmarshal

api.go:331–349  ·  view source on GitHub ↗
(contentType string, data []byte, v any)

Source from the content-addressed store, hash-verified

329}
330
331func (a *api) Unmarshal(contentType string, data []byte, v any) error {
332 start, end, err := parseContentType(contentType)
333 if err != nil {
334 return err
335 }
336
337 ct := contentType[start:end]
338 if ct == "" {
339 // Default to assume JSON since this is an API.
340 ct = "application/json"
341 }
342
343 f, ok := a.formats[ct]
344 if !ok {
345 return fmt.Errorf("%w: %s", ErrUnknownContentType, contentType)
346 }
347
348 return f.Unmarshal(data, v)
349}
350
351func (a *api) Negotiate(accept string) (string, error) {
352 ct := negotiation.SelectQValueFast(accept, a.formatKeys)

Callers

nothing calls this directly

Calls 2

parseContentTypeFunction · 0.85
UnmarshalMethod · 0.65

Tested by

no test coverage detected