Version: v0.0.0-...-ed73c64 Latest Latest

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

Go to latest
Published: Apr 4, 2021 License: Apache-2.0 Imports: 5 Imported by: 0



Package accept provides functions for handling HTTP content negotiation headers.



This section is empty.


This section is empty.


This section is empty.


type Header []MediaRange

A Header represents a set of media ranges as sent in the Accept header of an HTTP request.

func ParseHeader

func ParseHeader(accept string) (Header, error)

ParseHeader parses an Accept header of an HTTP request. The media ranges are unsorted.

func (Header) Quality

func (h Header) Quality(contentType string, params map[string][]string) float32

Quality returns the quality of a content type based on the media ranges in h.

func (Header) String

func (h Header) String() string

String formats the media ranges in the format for an Accept header.

type MediaRange

type MediaRange struct {
	Range   string
	Quality float32
	Params  map[string][]string

A MediaRange represents a set of MIME types as sent in the Accept header of an HTTP request.

func (*MediaRange) Match

func (mr *MediaRange) Match(contentType string, params map[string][]string) bool

Match reports whether the range applies to a content type.

func (*MediaRange) String

func (mr *MediaRange) String() string

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL