Skip to content

Commit

Permalink
return HTTP429 status code from HTTP API
Browse files Browse the repository at this point in the history
  • Loading branch information
tgross committed Jun 28, 2022
1 parent 9930183 commit d94a613
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions command/agent/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -528,6 +528,9 @@ func errCodeFromHandler(err error) (int, string) {
} else if strings.HasSuffix(errMsg, structs.ErrJobRegistrationDisabled.Error()) {
errMsg = structs.ErrJobRegistrationDisabled.Error()
code = 403
} else if strings.HasSuffix(errMsg, structs.ErrTooManyRequests.Error()) {
errMsg = structs.ErrTooManyRequests.Error()
code = 429
}
}

Expand Down Expand Up @@ -570,6 +573,9 @@ func (s *HTTPServer) wrap(handler func(resp http.ResponseWriter, req *http.Reque
} else if strings.HasSuffix(errMsg, structs.ErrIncompatibleFiltering.Error()) {
errMsg = structs.ErrIncompatibleFiltering.Error()
code = 400
} else if strings.HasSuffix(errMsg, structs.ErrTooManyRequests.Error()) {
errMsg = structs.ErrTooManyRequests.Error()
code = 429
}
}

Expand Down

0 comments on commit d94a613

Please sign in to comment.