Skip to content

Commit

Permalink
Merge pull request #679 from distribworks/fix_671
Browse files Browse the repository at this point in the history
fix: Return the correct status code on leader endpoint
  • Loading branch information
Victor Castell authored Feb 12, 2020
2 parents 7da930c + a628c39 commit ea0ea8b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions dkron/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,13 @@ func (h *HTTPTransport) membersHandler(c *gin.Context) {

func (h *HTTPTransport) leaderHandler(c *gin.Context) {
member, err := h.agent.leaderMember()
if err == nil {
renderJSON(c, http.StatusOK, member)
if err != nil {
c.AbortWithError(http.StatusInternalServerError, err)
}
if member == nil {
c.AbortWithStatus(http.StatusNotFound)
}
renderJSON(c, http.StatusOK, member)
}

func (h *HTTPTransport) leaveHandler(c *gin.Context) {
Expand Down

0 comments on commit ea0ea8b

Please sign in to comment.