fix: fixed a json encoding issue that caused the api.rest controller to return an empty list of events when a net.sniff http event is triggered

This commit is contained in:
evilsocket 2018-09-27 16:09:11 +02:00
parent 7b7739358d
commit 0ada0fdf7b
4 changed files with 46 additions and 16 deletions

View file

@ -40,7 +40,9 @@ func setSecurityHeaders(w http.ResponseWriter) {
func toJSON(w http.ResponseWriter, o interface{}) {
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(o)
if err := json.NewEncoder(w).Encode(o); err != nil {
log.Error("error while encoding object to JSON: %v", err)
}
}
func (api *RestAPI) checkAuth(r *http.Request) bool {