GitHub - jchannon/negotiator: A content negotiation package for web applications in Go

1 min read Original article ↗

This is a libary that handles content negotiation in web applications written in Go.

func getUser(w http.ResponseWriter, req *http.Request) {
    user := &User{"Joe","Bloggs"}
    if err := negotiator.Negotiate(w, req, user); err != nil {
      http.Error(w, err.Error(), http.StatusInternalServerError)
    }
}

To add your own negotiator, for example you want to write a PDF with your model, do the following: