Documentation
¶
Overview ¶
Package implement HTTP Content-Type and Accept header parsers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // Media type in the Content-Type or Accept header is syntactically invalid. ErrInvalidMediaType = errors.New("Invalid media type") // Range of media types in the Content-Type or Accept header is syntactically invalid. ErrInvalidMediaRange = errors.New("Invalid media range") // Media type parameter in the Content-Type or Accept header is syntactically invalid. ErrInvalidParameter = errors.New("Invalid parameter") // Media type extension parameter in the Content-Type or Accept header is syntactically invalid. ErrInvalidExtensionParameter = errors.New("Invalid extension parameter") // Accept header contains only media types that are not in the acceptable media type list. ErrNoAcceptableTypeFound = errors.New("No acceptable type found") // Acceptbale media type list is empty. ErrNoAvailableTypeGiven = errors.New("No available type given") // Media type weight in the Accept header is syntactically invalid. ErrInvalidWeight = errors.New("Invalid wieght") )
Functions ¶
func GetAcceptableMediaType ¶
func GetAcceptableMediaType(request *http.Request, availableMediaTypes []MediaType) (MediaType, Parameters, error)
Choses a media type from available media types according to the Accept. Returns the most suitable media type or an error if no type can be selected.
Types ¶
type MediaType ¶
type MediaType struct {
Type string
Subtype string
Parameters Parameters
}
A struct for media type which holds type, subtype and parameters.
func GetMediaType ¶
Gets the content of Content-Type header, parses it, and returns the parsed MediaType. If the request does not contain the Content-Type header, an empty MediaType is returned.
func NewMediaType ¶
Parses the string and returns an instance of MediaType struct.
Click to show internal directories.
Click to hide internal directories.