## HTTP Negotiation

## Installation

```shell
go get gitlab.schukai.com/oss/libraries/go/application/http-negotiation
```

**Note:** This library uses [Go Modules](https://github.com/golang/go/wiki/Modules) to manage dependencies.

## What do this library?

This library provides a simple way to negotiate the content type of HTTP request.

It supports:

* [x] [Content Negotiation](https://developer.mozilla.org/en-US/docs/Web/HTTP/Content_negotiation)
* [x] [Accept-Language](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Language)
* [x] [Accept-Charset](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Charset)
* [x] [Accept-Encoding](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept-Encoding)

## Usage

```go
package main

import (
	"net/http"
	"gitlab.schukai.com/oss/libraries/go/application/http-negotiation"
)

func handleRequest(w http.ResponseWriter, r *http.Request) {
	n := negotiation.New(r.Header)

	if n.Type("application/json") == "application/json" {
		w.Header().Set("Content-Type", "application/json")
		w.Write([]byte(`{"message": "Hello World!"}`))
		return
	}

}

```

## Contributing

Merge requests are welcome. For major changes, please open an issue first to discuss what 
you would like to change.

Please make sure to update tests as appropriate.

## License

[AGPL-3.0](https://choosealicense.com/licenses/agpl-3.0/)