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

Function parseContentType

api.go:429–444  ·  view source on GitHub ↗
(contentType string)

Source from the content-addressed store, hash-verified

427}
428
429func parseContentType(contentType string) (int, int, error) {
430 // Handle e.g. `application/json; charset=utf-8` or `my/format+json`
431 start := strings.IndexRune(contentType, '+') + 1
432 end := strings.IndexRune(contentType, ';')
433 if end == -1 {
434 end = len(contentType)
435 }
436
437 if end < start {
438 // This can happen if the `+` is after the `;`, which is not expected,
439 // but we should handle it gracefully.
440 return 0, 0, fmt.Errorf("%w: %s", ErrUnknownContentType, contentType)
441 }
442
443 return start, end, nil
444}
445
446// NewAPI creates a new API with the given configuration and router adapter.
447// You usually don't need to use this function directly, and can instead use

Callers 2

UnmarshalMethod · 0.85
MarshalMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…