Skip to content

Commit

Permalink
error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-goodisman committed May 7, 2024
1 parent 6f785b5 commit 3e5d8b9
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/denylist/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,11 @@ func createDenylistEntry(response http.ResponseWriter, request *http.Request, de
denylist.Store(id, true)
log.Log.Infow("Created denylist entry", "id", id)
metricFilterEnabled.WithLabelValues(id).Set(1)
syncer.StoreDenylistEntry(denylist, id)
err := syncer.StoreDenylistEntry(denylist, id)
if err != nil {
http.Error(response, "failed to persist removal of denylist entry", http.StatusInternalServerError)
return
}

response.WriteHeader(http.StatusCreated)
}
Expand All @@ -123,7 +127,11 @@ func deleteDenylistEntry(response http.ResponseWriter, request *http.Request, de
denylist.Delete(id)
log.Log.Infow("Deleted denylist entry", "id", id)
metricFilterEnabled.WithLabelValues(id).Set(0)
syncer.DeleteDenylistEntry(denylist, id)
err := syncer.DeleteDenylistEntry(denylist, id)
if err != nil {
http.Error(response, "failed to persist removal of denylist entry", http.StatusInternalServerError)
return
}

response.WriteHeader(http.StatusNoContent)
}

0 comments on commit 3e5d8b9

Please sign in to comment.