// Respond to an HTTP request by marshaling a value to JSON
Respond to an HTTP request by marshaling a value to JSON
// Respond to an HTTP request by marshaling a value to JSON
func JsonResponse(w http.ResponseWriter, val interface{}, code ...int) {
	b, err := json.Marshal(val)
	if err != nil {
		http.Error(w, err.Error(), http.StatusInternalServerError)
		return
	}
	w.Header().Set("Content-Type", "application/json")
	w.Header().Set("Cache-Control", "no-store")
	w.Header().Set("Pragma", "no-cache")
	if len(code) > 0 {
		w.WriteHeader(code[0])
	} else {
		w.WriteHeader(200)
	}
	w.Write(b)
}
func JsonResponse ( w http . ResponseWriter , val interface { } , code ... int ) { b , err := json . Marshal ( val ) if err != nil { http . Error ( w , err . Error ( ) , http . StatusInternalServerError ) return } w . Header ( ) . Set ( " " , " " ) w . Header ( ) . Set ( " " , " " ) w . Header ( ) . Set ( " " , " " ) if len ( code ) > 0 { w . WriteHeader ( code [ 0 ] ) } else { w . WriteHeader ( 200 ) } w . Write ( b ) }
Respond to an HTTP request by marshaling a value to JSON
Respond to an HTTP request by marshaling a value to JSON