package httputil import ( "strings" ) const ( baseContentType = "application" ) func ContentType(subtype string) string { return strings.Join([]string{baseContentType, subtype}, "/") } func ContentSubtype(contentType string) string { left := strings.Index(contentType, "/") if left == -1 { return "" } right := strings.Index(contentType, ";") if right == -1 { right = len(contentType) } right1 := strings.Index(contentType, ",") if right1 > 0 && right1 < right { right = right1 } if right < left { return "" } return contentType[left+1 : right] }