mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-22 17:42:14 +08:00
Update json.go
This commit is contained in:
parent
b90df5cb17
commit
456391692c
@ -68,11 +68,8 @@ func WriteJSON(w http.ResponseWriter, obj interface{}) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = w.Write(jsonBytes)
|
_, err = w.Write(jsonBytes)
|
||||||
if err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// Render (IndentedJSON) marshals the given interface object and writes it with custom ContentType.
|
// Render (IndentedJSON) marshals the given interface object and writes it with custom ContentType.
|
||||||
func (r IndentedJSON) Render(w http.ResponseWriter) error {
|
func (r IndentedJSON) Render(w http.ResponseWriter) error {
|
||||||
@ -140,9 +137,13 @@ func (r JsonpJSON) Render(w http.ResponseWriter) (err error) {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
_, err = w.Write([]byte(")"))
|
_, err = w.Write([]byte(")"))
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// WriteContentType (JsonpJSON) writes Javascript ContentType.
|
// WriteContentType (JsonpJSON) writes Javascript ContentType.
|
||||||
func (r JsonpJSON) WriteContentType(w http.ResponseWriter) {
|
func (r JsonpJSON) WriteContentType(w http.ResponseWriter) {
|
||||||
writeContentType(w, jsonpContentType)
|
writeContentType(w, jsonpContentType)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user