Skip to content

Commit

Permalink
chore: changed http status and error message to be more user-friendly
Browse files Browse the repository at this point in the history
Signed-off-by: Dmitry Kisler <[email protected]>
  • Loading branch information
kislerdm committed Sep 8, 2023
1 parent 898f55c commit 9d55528
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions server/core/ciam/httphandler.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func (c client) validateRequestsQuotaUsage(w http.ResponseWriter, r *http.Reques
}

if quotasUsage.RateDay.Used >= quotasUsage.RateDay.Limit {
w.WriteHeader(http.StatusForbidden)
_, _ = w.Write([]byte(`{"error":"quota exceeded"}`))
w.WriteHeader(http.StatusTooManyRequests)
_, _ = w.Write([]byte(`{"error":"daily quota exceeded"}`))
c.logger.Printf("quota exceeded for user %s", user.ID)
return false
}
Expand Down
4 changes: 2 additions & 2 deletions server/core/ciam/iam_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ func Test_client_validateRequestsQuotaUsage(t *testing.T) {
user: &User{},
writer: &utils.MockWriter{},
},
wantStatuCode: http.StatusForbidden,
wantBody: []byte(`{"error":"quota exceeded"}`),
wantStatuCode: http.StatusTooManyRequests,
wantBody: []byte(`{"error":"daily quota exceeded"}`),
want: false,
},
{
Expand Down

0 comments on commit 9d55528

Please sign in to comment.