Exemplo n.º 1
0
func makeEchoValueHandler(expected string, t *testing.T) HandlerFunc {
	return func(value string, w http.ResponseWriter, r *http.Request) {
		if expected != value {
			t.Fatalf("expected %v, got %v in handler", expected, value)
		}
		buf := util.StringToBytes(value)
		w.Header().Add("Content-Length", strconv.Itoa(len(buf)))
		w.Write(buf)
	}
}
Exemplo n.º 2
0
func constHandler(value string, w http.ResponseWriter, r *http.Request) {
	buf := util.StringToBytes("constHandler")
	w.Header().Add("Content-Length", strconv.Itoa(len(buf)))
	w.Write(buf)
}