(contentType string, data []byte, v any)
| 329 | } |
| 330 | |
| 331 | func (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 | |
| 351 | func (a *api) Negotiate(accept string) (string, error) { |
| 352 | ct := negotiation.SelectQValueFast(accept, a.formatKeys) |
nothing calls this directly
no test coverage detected