You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

26 lines
471 B

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)
}
if right < left {
return ""
}
return contentType[left+1 : right]
}