MCPcopy Create free account
hub / github.com/evilsocket/pwngrid / JSON

Function JSON

api/utils.go:51–66  ·  view source on GitHub ↗
(w http.ResponseWriter, statusCode int, data interface{})

Source from the content-addressed store, hash-verified

49}
50
51func JSON(w http.ResponseWriter, statusCode int, data interface{}) {
52 js, err := json.Marshal(data)
53 if err != nil {
54 http.Error(w, err.Error(), http.StatusInternalServerError)
55 return
56 }
57
58 w.Header().Set("Content-Type", "application/json")
59 w.WriteHeader(statusCode)
60
61 if sent, err := w.Write(js); err != nil {
62 log.Error("error sending response: %v", err)
63 } else {
64 log.Debug("sent %d bytes of json response", sent)
65 }
66}
67
68func ERROR(w http.ResponseWriter, statusCode int, err error) {
69 if err != nil {

Callers 15

UnitEnrollMethod · 0.85
PeerGetDataMethod · 0.85
PeerSetDataMethod · 0.85
GetInboxMethod · 0.85
GetInboxMessageMethod · 0.85
MarkInboxMessageMethod · 0.85
SendMessageToMethod · 0.85
ERRORFunction · 0.85
UnitReportAPMethod · 0.85
UnitReportMultipleAPMethod · 0.85
ListUnitsMethod · 0.85
UnitsByCountryMethod · 0.85

Calls 1

WriteMethod · 0.80

Tested by

no test coverage detected