Skip to content

Commit

Permalink
coprocess: provide original URL to error handler (#2859)
Browse files Browse the repository at this point in the history
Additional tweak for #2837, extends #2638.

(cherry picked from commit 94da1f2)
  • Loading branch information
matiasinsaurralde authored and Tyk Bot committed Feb 2, 2020
1 parent 4e55781 commit 9cc09e7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gateway/coprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ func (m *CoProcessMiddleware) EnabledForSpec() bool {
func (m *CoProcessMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Request, _ interface{}) (error, int) {
logger := m.Logger()
logger.Debug("CoProcess Request, HookType: ", m.HookType)
originalURL := r.URL

var extractor IdExtractor
if m.Spec.EnableCoProcessAuth && m.Spec.CustomMiddleware.IdExtractor.Extractor != nil {
Expand Down Expand Up @@ -304,6 +305,8 @@ func (m *CoProcessMiddleware) ProcessRequest(w http.ResponseWriter, r *http.Requ

err = coProcessor.ObjectPostProcess(returnObject, r)
if err != nil {
// Restore original URL object so that it can be used by ErrorHandler:
r.URL = originalURL
logger.WithError(err).Error("Failed to post-process request object")
return errors.New("Middleware error"), 500
}
Expand Down

0 comments on commit 9cc09e7

Please sign in to comment.