예제 #1
0
func ModelNegotiator() *negotiator.Negotiator {
	return negotiator.New(
		&HTMLTemplatePBResponseProcessor{},
		&JSONPBResponseProcessor{},
		&RawPBResponseProcessor{},
	)
}
예제 #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)
}
예제 #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)
}