conneg

package
v0.0.0-...-5011a96 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package conneg provides HTTP content negotiation support.

Index

Constants

This section is empty.

Variables

View Source
var ErrMatchNotFound = errors.New("no matching media type found")

ErrMatchNotFound indicates that a matching media type was not available. This error corresponds to a HTTP 406 Not Acceptable status code.

Functions

func MatchContentType

func MatchContentType(accept string, offers ...string) (string, error)

MatchContentType parses accept and returns the best match from offers.

Types

type MediaType

type MediaType struct {
	// contains filtered or unexported fields
}

MediaType represents a media type as per [RFC 1521].

[RFC 1521]:https://www.rfc-editor.org/rfc/rfc1521.html

func ParseContentType

func ParseContentType(s string) ([]MediaType, error)

ParseContentType parses a content-type into a slice of media types.

func (*MediaType) Matches

func (m *MediaType) Matches(t string) bool

Matches returns true if t matches m.

func (*MediaType) String

func (m *MediaType) String() string

String implements fmt.Stringer.

Jump to

Keyboard shortcuts

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