Call the AuthZRes function also when the daemon returns error

Signed-off-by: Ezra Silvera <ezra@il.ibm.com>
This commit is contained in:
Ezra Silvera 2016-10-11 01:13:48 +03:00
parent 9115b65ffd
commit 5a8ff40254

View file

@ -55,15 +55,21 @@ func (m *Middleware) WrapHandler(handler func(ctx context.Context, w http.Respon
rw := NewResponseModifier(w)
if err := handler(ctx, rw, r, vars); err != nil {
logrus.Errorf("Handler for %s %s returned error: %s", r.Method, r.RequestURI, err)
return err
var errD error
if errD = handler(ctx, rw, r, vars); errD != nil {
logrus.Errorf("Handler for %s %s returned error: %s", r.Method, r.RequestURI, errD)
}
if err := authCtx.AuthZResponse(rw, r); err != nil {
if err := authCtx.AuthZResponse(rw, r); errD == nil && err != nil {
logrus.Errorf("AuthZResponse for %s %s returned error: %s", r.Method, r.RequestURI, err)
return err
}
if errD != nil {
return errD
}
return nil
}
}