Skip to content

Commit

Permalink
Coprocess plugins should be able to override error messages
Browse files Browse the repository at this point in the history
Use `Request.ReturnOverrides.ResponseError`, and retain compatibility
by serving default error message.
  • Loading branch information
buger committed Aug 4, 2017
1 parent 84b0086 commit c15f806
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion coprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,12 @@ func (m *CoProcessMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Requ
// Report in health check
ReportHealthCheckValue(m.Spec.Health, KeyFailure, "1")

return errors.New("Key not authorised"), int(returnObject.Request.ReturnOverrides.ResponseCode)
errorMsg := "Key not authorised"
if returnObject.Request.ReturnOverrides.ResponseError != "" {
errorMsg = returnObject.Request.ReturnOverrides.ResponseError
}

return errors.New(errorMsg), int(returnObject.Request.ReturnOverrides.ResponseCode)
}

if returnObject.Request.ReturnOverrides.ResponseCode > 0 {
Expand Down

0 comments on commit c15f806

Please sign in to comment.