accept

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: BSD-3-Clause Imports: 2 Imported by: 0

README

Build Status Coverage Status Go Reference

accept

Check the Accept-* http headers if the given value is accepted.

Example:

if accept.Encoding(req.Header.Get("Accept-Encoding"), "deflate") {
    w.Header().Set("Content-Encoding", "deflate")
    // go with the deflate compression..
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Encoding

func Encoding(header, val string) bool

Encoding checks if the given encoding val is acceptable according to the Accept-Encoding header. See https://www.rfc-editor.org/rfc/rfc7231#section-5.3.4 .

If header is empty/nonexistent, the RFC says, "the user agent has no preferences regarding content-codings", and also "it does not imply that the user agent will be able to correctly process all encodings", so we assume it will not, and return false. Empty val also means that this check fails.

Types

This section is empty.

Jump to

Keyboard shortcuts

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