negotiate

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package negotiate provides HTTP content negotiation utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Accept

func Accept(header string, offers []string) string

Accept returns the best matching offer based on the Accept header value. Returns "" if no offer matches.

func MatchMedia

func MatchMedia(pattern, offer string) bool

MatchMedia returns true if the Accept pattern matches the offered media type. Supports wildcards: "*/*" matches everything, "text/*" matches any text subtype.

Types

type AcceptItem

type AcceptItem struct {
	MediaType string
	Quality   float64
}

AcceptItem represents a parsed Accept header entry with media type and quality.

func Parse

func Parse(header string) []AcceptItem

Parse parses an Accept header value into a slice of AcceptItems.

Jump to

Keyboard shortcuts

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