acceptable

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: MIT Imports: 9 Imported by: 1

README

go-acceptable

Go library for HTTP content negotiation

Documentation

Index

Constants

View Source
const (
	MinQuality = 0
	MaxQuality = 1000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Acceptable

type Acceptable struct {
	Value    string
	SubValue string
	Params   map[string]string
	Quality  Quality
}

func Negotiate

func Negotiate(available, preferences List) (Acceptable, bool)

func (Acceptable) Append

func (a Acceptable) Append(out []byte) []byte

func (Acceptable) CompareTo

func (a Acceptable) CompareTo(b Acceptable) int

func (Acceptable) EqualTo

func (a Acceptable) EqualTo(b Acceptable) bool

func (Acceptable) MarshalText

func (a Acceptable) MarshalText() ([]byte, error)

func (*Acceptable) Parse

func (a *Acceptable) Parse(input string, mode SubValueMode) error

func (Acceptable) String

func (a Acceptable) String() string

func (*Acceptable) UnmarshalText

func (a *Acceptable) UnmarshalText(input []byte) error

type List

type List []Acceptable

func (List) Append

func (list List) Append(out []byte) []byte

func (List) IsSorted

func (list List) IsSorted() bool

func (List) Len

func (list List) Len() int

func (List) Less

func (list List) Less(i, j int) bool

func (List) MarshalText

func (list List) MarshalText() ([]byte, error)

func (*List) Parse

func (list *List) Parse(input string, mode SubValueMode) error

func (List) Sort

func (list List) Sort()

func (List) String

func (list List) String() string

func (List) Swap

func (list List) Swap(i, j int)

func (*List) UnmarshalText

func (list *List) UnmarshalText(input []byte) error

type Quality

type Quality uint

func (Quality) Append

func (q Quality) Append(out []byte) []byte

func (Quality) CompareTo

func (q Quality) CompareTo(other Quality) int

func (Quality) GoString

func (q Quality) GoString() string

func (Quality) MarshalText

func (q Quality) MarshalText() ([]byte, error)

func (*Quality) Parse

func (q *Quality) Parse(input string) error

func (Quality) String

func (q Quality) String() string

func (*Quality) UnmarshalText

func (q *Quality) UnmarshalText(input []byte) error

type SubValueMode

type SubValueMode uint
const (
	OptionalSubValue SubValueMode = iota
	RequiredSubValue
	AbsentSubValue
)

Jump to

Keyboard shortcuts

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