accept

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2020 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Negotiate

func Negotiate(asks, offers []string) (int, int)

Negotiate returns the best offered content type for the request's Accept header. If two offers match with equal weight, then the more specific offer is preferred. For example, text/* trumps */*. If two offers match with equal weight and specificity, then the offer earlier in the list is preferred. If no offers match, then defaultOffer is returned.

func ParseValueAndParams

func ParseValueAndParams(s string) (value string, params map[string]string)

ParseValueAndParams parses a comma separated list of values with optional semicolon separated name-value pairs. Content-Type and Content-Disposition headers are in this format.

Types

type AcceptSpec

type AcceptSpec struct {
	Value string
	Q     float64
	Index int
}

AcceptSpec describes an Accept* header.

func Parse

func Parse(parts []string) (specs []AcceptSpec)

Parse parses Accept* kind headers.

Jump to

Keyboard shortcuts

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