https://github.com/k-phoen/http-negotiate
[DEPRECATED] Content negotiation HTTP middleware for Go
https://github.com/k-phoen/http-negotiate
Last synced: 26 days ago
JSON representation
[DEPRECATED] Content negotiation HTTP middleware for Go
- Host: GitHub
- URL: https://github.com/k-phoen/http-negotiate
- Owner: K-Phoen
- License: mit
- Created: 2014-10-14T09:40:00.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-05-29T19:10:20.000Z (almost 9 years ago)
- Last Synced: 2024-05-01T20:12:59.366Z (12 months ago)
- Language: Go
- Homepage:
- Size: 2.93 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
negotiate
=========Content negotiation HTTP middleware for Go applications.
It's a simple wrapper around my [negotiation library](https://github.com/K-Phoen/negotiation)
which implements the `http.Handler` interface.## Status
This project is **DEPRECATED** and should NOT be used.
If someone magically appears and wants to maintain this project, I'll gladly give access to this repository.
## Usage
Here is a ready to use example with [Negroni](https://github.com/codegangsta/negroni):
```go
package mainimport (
"fmt"
"net/http""github.com/codegangsta/negroni"
"github.com/K-Phoen/http-negotiate/negotiate"
)func main() {
mux := http.NewServeMux()
mux.HandleFunc("/", func(w http.ResponseWriter, req *http.Request) {
fmt.Fprintf(w, "Welcome to the home page!")
fmt.Fprintf(w, "The negotiated format is: " + w.Header().Get("Content-Type"))
})n := negroni.Classic()
n.Use(negotiate.FormatNegotiator([]string{"application/json", "application/xml"}))
n.UseHandler(mux)
n.Run(":3000")
}
```## ToDo
* provide tools to negotiate other things (language for instance)
* write tests## License
This library is released under the MIT License. See the bundled LICENSE file for
details.