Skip to content

Commit

Permalink
Add JSONP back
Browse files Browse the repository at this point in the history
  • Loading branch information
fiorix committed Mar 15, 2016
1 parent 49f2e45 commit 7969483
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions apiserver/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,17 @@ func xmlWriter(w http.ResponseWriter, r *http.Request, d *responseRecord) {
}

func jsonWriter(w http.ResponseWriter, r *http.Request, d *responseRecord) {
if cb := r.FormValue("callback"); cb != "" {
w.Header().Set("Content-Type", "application/javascript")
io.WriteString(w, cb)
w.Write([]byte("("))
b, err := json.Marshal(d)
if err == nil {
w.Write(b)
}
io.WriteString(w, ");")
return
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(d)
}
Expand Down

0 comments on commit 7969483

Please sign in to comment.