mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-14 23:56:51 +08:00
Setting application/json for json result.
Setting application/javascript for jsonp result.
This commit is contained in:
@@ -25,7 +25,6 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func writeJson(w http.ResponseWriter, r *http.Request, obj interface{}) (err error) {
|
func writeJson(w http.ResponseWriter, r *http.Request, obj interface{}) (err error) {
|
||||||
w.Header().Set("Content-Type", "application/javascript")
|
|
||||||
var bytes []byte
|
var bytes []byte
|
||||||
if r.FormValue("pretty") != "" {
|
if r.FormValue("pretty") != "" {
|
||||||
bytes, err = json.MarshalIndent(obj, "", " ")
|
bytes, err = json.MarshalIndent(obj, "", " ")
|
||||||
@@ -37,8 +36,10 @@ func writeJson(w http.ResponseWriter, r *http.Request, obj interface{}) (err err
|
|||||||
}
|
}
|
||||||
callback := r.FormValue("callback")
|
callback := r.FormValue("callback")
|
||||||
if callback == "" {
|
if callback == "" {
|
||||||
|
w.Header().Set("Content-Type", "application/json")
|
||||||
_, err = w.Write(bytes)
|
_, err = w.Write(bytes)
|
||||||
} else {
|
} else {
|
||||||
|
w.Header().Set("Content-Type", "application/javascript")
|
||||||
if _, err = w.Write([]uint8(callback)); err != nil {
|
if _, err = w.Write([]uint8(callback)); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user