From 84126f9425b4e61d45747519df4dadc769b3abd8 Mon Sep 17 00:00:00 2001 From: Maycon Santos Date: Thu, 8 May 2025 00:01:20 +0200 Subject: [PATCH] add too many requests status --- management/server/http/handlers/peers/peers_handler.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/management/server/http/handlers/peers/peers_handler.go b/management/server/http/handlers/peers/peers_handler.go index fdfcce261..a54ec91e8 100644 --- a/management/server/http/handlers/peers/peers_handler.go +++ b/management/server/http/handlers/peers/peers_handler.go @@ -107,7 +107,7 @@ func (h *Handler) updatePeer(ctx context.Context, accountID, userID, peerID stri req := &api.PeerRequest{} err := json.NewDecoder(r.Body).Decode(&req) if err != nil { - util.WriteErrorResponse("couldn't parse JSON request", http.StatusBadRequest, w) + util.WriteErrorResponse("couldn't parse JSON request", http.StatusPreconditionRequired, w) return } @@ -204,7 +204,7 @@ func (h *Handler) HandlePeer(w http.ResponseWriter, r *http.Request) { // GetAllPeers returns a list of all peers associated with a provided account func (h *Handler) GetAllPeers(w http.ResponseWriter, r *http.Request) { if !h.rateLimiter.Allow() { - util.WriteError(r.Context(), fmt.Errorf("temp rate limit reached"), w) + util.WriteError(r.Context(), status.Errorf(status.StatusTooManyRequests, "temp rate limit reached"), w) return } userAuth, err := nbcontext.GetUserAuthFromContext(r.Context())