diff --git a/README.md b/README.md index 9de658b93e1a64127b20e68ccd60d0a72eb9735a..e5954576a9ca19ad7a5723179eb0be1362be07bc 100644 --- a/README.md +++ b/README.md @@ -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