// Encode encodes the given content using the given media type and returns
// a string with the encoded data.
Encode encodes the given content using the given media type and returns
a string with the encoded data.
// Encode encodes the given content using the given media type and returns // a string with the encoded data .
func Encode(content []byte, mediaType MediaType) (string, error) {
	switch mediaType {
	case GzipMediaType:
		return GzipCompress(content)
	case JSONMediaType:
		return string(content), nil
	case "":
		return "", fmt.Errorf("media type not specified")
	default:
		return "", fmt.Errorf("unsupported media type [%s]", mediaType)
	}
}
func Encode ( content [ ] byte , mediaType MediaType ) ( string , error ) { switch mediaType { case GzipMediaType : return GzipCompress ( content ) case JSONMediaType : return string ( content ) , nil case " " : return " " , fmt . Errorf ( " " ) default : return " " , fmt . Errorf ( " " , mediaType ) } }
Encode encodes the given content using the given media type and returns
a string with the encoded data.
Encode encodes the given content using the given media type and returns a string with the encoded data .