Utility library that can parse the Accept*
header to pull out encodings/languages/charsets/mimetypes for use by an API.
import "github.com/Svjard/goaccepts"
// Header sent in request with "en-US, it;q=0.6"
...
goaccepts.Languages(res.headers["Accept-Language"])
// will return []string{"en-US","it"}
Each header type is seperated into its own file and parser.
Accept - media-type.go
Accept-Encoding - encoding.go
Accept-Charset - charset.go
Accept-Language - language.go
RFC Reference: https://tools.ietf.org/html/rfc2616
Each module has two specific functions, the first returns a raw string array representation of the accepted entities in order of weight. The second returns an array of structures which provides a specific breakdown and detail about each parsed entity.
To run the test suite run the following command:
go test -v ./...
To run the code coverage report run the following command:
./go.test.sh