Skip to content
Snippets Groups Projects
Verified Commit 1b336cc0 authored by Volker Schukai's avatar Volker Schukai :alien:
Browse files

add documentation

parent b4802679
No related branches found
No related tags found
No related merge requests found
......@@ -21,12 +21,16 @@ It supports:
## Usage
### Content Negotiation
With the `Type` function you can negotiate the content type of HTTP request.
```go
package main
import (
"net/http"
"gitlab.schukai.com/oss/libraries/go/application/http-negotiation"
"gitlab.schukai.com/oss/libraries/go/network/http-negotiation"
)
func handleRequest(w http.ResponseWriter, r *http.Request) {
......@@ -42,6 +46,75 @@ func handleRequest(w http.ResponseWriter, r *http.Request) {
```
### Language Negotiation
With the `Language` function you can negotiate the language of HTTP request.
```go
package main
import (
"net/http"
"gitlab.schukai.com/oss/libraries/go/network/http-negotiation"
)
func handleRequest(w http.ResponseWriter, r *http.Request) {
n := negotiation.New(r.Header)
if n.Language("en-GB", "en") != "en" {
// ...
}
}
```
### Charset Negotiation
With the `Charset` function you can negotiate the charset of HTTP request.
```go
package main
import (
"net/http"
"gitlab.schukai.com/oss/libraries/go/network/http-negotiation"
)
func handleRequest(w http.ResponseWriter, r *http.Request) {
n := negotiation.New(r.Header)
if n.Charset("utf-8", "iso-8859-1") != "utf-8" {
// ...
}
}
```
### Encoding Negotiation
With the `Encoding` function you can negotiate the encoding of HTTP request.
```go
package main
import (
"net/http"
"gitlab.schukai.com/oss/libraries/go/network/http-negotiation"
)
func handleRequest(w http.ResponseWriter, r *http.Request) {
n := negotiation.New(r.Header)
if n.Encoding("gzip", "deflate") != "gzip" {
// ...
}
}
```
## Contributing
Merge requests are welcome. For major changes, please open an issue first to discuss what
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment