Update json.go

This commit is contained in:
田欧 2019-01-20 17:39:10 +08:00 committed by GitHub
parent b90df5cb17
commit 456391692c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,11 +68,8 @@ func WriteJSON(w http.ResponseWriter, obj interface{}) error {
return err
}
_, err = w.Write(jsonBytes)
if err != nil {
return err
}
return nil
}
// Render (IndentedJSON) marshals the given interface object and writes it with custom ContentType.
func (r IndentedJSON) Render(w http.ResponseWriter) error {
@ -140,9 +137,13 @@ func (r JsonpJSON) Render(w http.ResponseWriter) (err error) {
return err
}
_, err = w.Write([]byte(")"))
if err != nil {
return err
}
return nil
}
// WriteContentType (JsonpJSON) writes Javascript ContentType.
func (r JsonpJSON) WriteContentType(w http.ResponseWriter) {
writeContentType(w, jsonpContentType)