Documentation
¶
Overview ¶
Package negotiation provides HTTP content negotiation helpers.
It handles Accept and Content-Type checks for APIs that need more than the simple JSON-only middleware.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContentTypeAllowed ¶
ContentTypeAllowed reports whether a Content-Type is allowed.
func RequireAccept ¶
RequireAccept returns middleware that enforces response media negotiation.
Types ¶
type Accept ¶
type Accept struct {
MediaType string
Type string
Subtype string
Params map[string]string
Q float64
Order int
}
Accept is one parsed Accept header item.
func ParseAccept ¶
ParseAccept parses an Accept header and sorts values by client preference.
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware enforces Accept and Content-Type policies.
func New ¶
func New(config Config) (*Middleware, error)
New constructs content negotiation middleware.
func (*Middleware) Handler ¶
func (m *Middleware) Handler(next http.Handler) http.Handler
Handler wraps next with Accept and Content-Type checks.
func (*Middleware) Middleware ¶
func (m *Middleware) Middleware() func(http.Handler) http.Handler
Middleware returns the standard middleware adapter.
Click to show internal directories.
Click to hide internal directories.