Ejemplo n.º 1
0
func TextHandler(h mohttp.DataHandlerFunc) mohttp.Handler {
	return mohttp.HandlerFunc(func(c context.Context) {
		r, _ := mohttp.GetDataResponder(c)

		if _, ok := r.(*TextResponder); !ok {
			c = mohttp.WithDataResponder(c, &TextResponder{})
		}

		h.Handle(c)
	})
}
Ejemplo n.º 2
0
func JSONHandler(fn mohttp.DataHandlerFunc) mohttp.Handler {
	return mohttp.HandlerFunc(func(c context.Context) {
		r, _ := mohttp.GetDataResponder(c)

		if _, ok := r.(*JSONResponder); !ok {
			c = mohttp.WithDataResponder(c, &JSONResponder{})
		}

		fn.Handle(c)
	})
}