func ModelNegotiator() *negotiator.Negotiator {
	return negotiator.New(
		&HTMLTemplatePBResponseProcessor{},
		&JSONPBResponseProcessor{},
		&RawPBResponseProcessor{},
	)
}
Beispiel #2
0
func negotiatormw(c *web.C, h http.Handler) http.Handler {
	fn := func(w http.ResponseWriter, r *http.Request) {
		c.Env["negotiator"] = negotiator.New(&responseprocessors.PlainTextResponseProcessor{})

		h.ServeHTTP(w, r)
	}
	return http.HandlerFunc(fn)
}
Beispiel #3
0
func customHandler(c web.C, w http.ResponseWriter, req *http.Request) error {
	user := &user{"Joe", "Bloggs"}
	//Creating the negotiator could be done for only required handlers or use middleware for all
	textplainNegotiator := negotiator.New(&responseprocessors.PlainTextResponseProcessor{})
	return textplainNegotiator.Negotiate(w, req, user)
}