util.go 235 Bytes Raw Blame History Permalink 1 2 3 4 5 6 7 8 9 10 11 12 package main import ( "encoding/json" "net/http" ) func WriteJson(w http.ResponseWriter, status int, data interface{}) { w.Header().Set("Content-Type", "application/json") w.WriteHeader(status) json.NewEncoder(w).Encode(data) }