MCPcopy Create free account
hub / github.com/conforma/cli / contentTypeFromString

Function contentTypeFromString

acceptance/wiremock/wiremock.go:102–114  ·  view source on GitHub ↗

contentTypeFromString returns the content-type part of a MIME media type for example given "type/subtype;parameter=value;..." returns "type/subtype"

(s string)

Source from the content-addressed store, hash-verified

100// contentTypeFromString returns the content-type part of a MIME media type
101// for example given "type/subtype;parameter=value;..." returns "type/subtype"
102func contentTypeFromString(s string) string {
103 for _, part := range strings.Split(s, ",") {
104 contentType, _, err := mime.ParseMediaType(part)
105 if err != nil {
106 continue
107 }
108
109 // first that parses without error
110 return contentType
111 }
112
113 return "unknown/unknown"
114}
115
116// contentTypeFrom returns the content-type based on the "Accept" HTTP
117// header of a HTTP request, given that HTTP headers can be multivalued

Callers 1

contentTypeFromFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected