github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/compress/compress-type.go (about) 1 /* For license and copyright information please see LEGAL file in repository */ 2 3 package compress 4 5 import ( 6 "../mediatype" 7 "../protocol" 8 ) 9 10 type CompressType struct { 11 mediatype *mediatype.MediaType 12 contentEncoding string 13 extension string 14 } 15 16 func (ct *CompressType) MediaType() protocol.MediaType { return ct.mediatype } 17 func (ct *CompressType) ContentEncoding() string { return ct.contentEncoding } 18 func (ct *CompressType) FileExtension() string { return ct.extension } 19 20 func New(contentEncoding string, mediatype *mediatype.MediaType) (ct *CompressType) { 21 if mediatype == nil { 22 panic("CompressType doesn't has a valid MediaType. Can't make it.") 23 } 24 if contentEncoding == "" { 25 panic("CompressType doesn't has a valid ContentEncoding. Can't make it.") 26 } 27 ct = &CompressType{ 28 mediatype: mediatype, 29 contentEncoding: contentEncoding, 30 extension: mediatype.FileExtension(), 31 } 32 return 33 }