github.com/geniusesgroup/libgo@v0.0.0-20220713101832-828057a9d3d4/protocol/media-type.go (about)

     1  /* For license and copyright information please see LEGAL file in repository */
     2  
     3  package protocol
     4  
     5  type MediaTypes interface {
     6  	RegisterMediaType(mt MediaType)
     7  	GetMediaType(mt string) MediaType
     8  	GetMediaTypeByID(id uint64) MediaType
     9  	GetMediaTypeByFileExtension(ex string) MediaType
    10  }
    11  
    12  // MediaType is standard shape of any coding media-type
    13  // MediaType or MimeType standard list can found here:
    14  // http://www.iana.org/assignments/media-types/media-types.xhtml
    15  // https://en.wikipedia.org/wiki/Media_type
    16  // https://tools.ietf.org/html/rfc6838
    17  // https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types
    18  // It must also implement our RFC details on https://github.com/GeniusesGroup/RFCs/blob/master/media-type.md
    19  // domain/sabz.city.storage+syllab; name=quiddity
    20  type MediaType interface {
    21  	// Below names are case-insensitive.
    22  	MainType() string     // must
    23  	Tree() string         // if any
    24  	SubType() string      // must
    25  	Suffix() string       // if any
    26  	Parameters() []string // if any
    27  
    28  	FileExtension() string // if any
    29  
    30  	UUID() [32]byte     // Hash of MediaType()
    31  	ID() uint64         // first 64bit of UUID
    32  	IDasString() string // Base64 of ID
    33  
    34  	Status() SoftwareStatus
    35  	IssueDate() Time
    36  	ExpiryDate() Time
    37  	ExpireInFavorOf() MediaType
    38  	Details() []MediaTypeDetail
    39  	Detail(lang LanguageID) MediaTypeDetail
    40  
    41  	Fields() []Field // In explicit mediatype like domain maintype not like "application/json"
    42  
    43  	Stringer // must "maintype "/" [tree "."] subtype ["+" suffix]* [";" parameters]"
    44  }
    45  
    46  type MediaTypeDetail interface {
    47  	Language() LanguageID
    48  	// Domain return locale domain name that MediaType belongs to it.
    49  	// More user friendly domain name to show to users on screens.
    50  	Domain() string
    51  	// Summary return locale general summary MediaType text that gives the main points in a concise form
    52  	Summary() string
    53  	// Overview return locale general MediaType text that gives the main ideas without explaining all the details
    54  	Overview() string
    55  	// UserNote return locale note that user do when face this MediaType
    56  	// Description text that gives the main ideas with explaining all the details and purposes.
    57  	UserNote() string
    58  	// DevNote return locale technical advice for developers
    59  	// Description text that gives the main ideas with explaining all the details and purposes.
    60  	DevNote() string
    61  	// TAGS return locale MediaType tags to sort MediaType in groups for any purpose e.g. in GUI to help org manager to give service delegate authorization to staffs.
    62  	TAGS() []string
    63  }