accept

package
v0.0.0-...-60192f8 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package accept provides a parser for HTTP Accept* headers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NegotiateContentEncoding

func NegotiateContentEncoding(h http.Header, offers []string) string

NegotiateContentEncoding returns the best offered content encoding for the request's Accept-Encoding header. If two offers match with equal weight and then the offer earlier in the list is preferred. If no offers are acceptable, then "" is returned.

func NegotiateContentType

func NegotiateContentType(h http.Header, offers []string, defaultOffer string) string

NegotiateContentType 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.

Types

type Spec

type Spec struct {
	Value string
	Q     float64
}

Spec describes an Accept* header.

func ParseAccept

func ParseAccept(header http.Header, key string) (specs []Spec)

ParseAccept parses Accept* headers.

Jump to

Keyboard shortcuts

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