http

package
v0.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 31, 2023 License: MIT Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcceptableTypes

type AcceptableTypes []*MediaType

func ParseAccept

func ParseAccept(values []string) (AcceptableTypes, error)

ParseAccept parses a set of Accept headers and scores them per the rules in RFC7231, returning a slice of headers in descending order of priority. If the Accept header occurs multiple times in the request the result of all headers will be combined and scored together as if they were all in one header line.

See: https://tools.ietf.org/html/rfc7231#section-5.3.2

func (AcceptableTypes) FindMatch

func (a AcceptableTypes) FindMatch(values AcceptableTypes) (match *MediaType, matcher *MediaType)

FindMatch returns the MediaType in the set that has the best match for the passed media types as well as the media type that determined the match. According to the rules of RFC7231, the most specific match wins in order of weight. This function assumes that both values are sorted.

func (AcceptableTypes) Len

func (a AcceptableTypes) Len() int

func (AcceptableTypes) Less

func (a AcceptableTypes) Less(i, j int) bool

func (AcceptableTypes) Sorted

func (a AcceptableTypes) Sorted() AcceptableTypes

func (AcceptableTypes) Swap

func (a AcceptableTypes) Swap(i, j int)

type MediaType

type MediaType struct {
	Type       string
	Subtype    string
	Parameters map[string]string
	Weight     float64
	// contains filtered or unexported fields
}

func ParseMediaType

func ParseMediaType(v string) (*MediaType, error)

func (MediaType) Equal

func (m MediaType) Equal(v MediaType) bool

func (MediaType) Satisfies

func (m MediaType) Satisfies(v MediaType) bool

func (MediaType) Specificity

func (m MediaType) Specificity() int

func (MediaType) String

func (m MediaType) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL