github.com/best4tires/kit@v1.0.5/srv/write.go (about) 1 package srv 2 3 import ( 4 "encoding/json" 5 "net/http" 6 ) 7 8 func WriteJSON(w http.ResponseWriter, status int, v any) { 9 w.Header().Add(HeaderContentType, ContentTypeJSONUTF8) 10 w.WriteHeader(status) 11 json.NewEncoder(w).Encode(v) 12 }