Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FilterChain should pass the request and response from filters to Target function #482

Merged
merged 1 commit into from Nov 24, 2021

Conversation

SVilgelm
Copy link
Contributor

The PR #478 brought some weird changes that breaks the filters behaviour.
We have a filter that creates another instance of Response to intercept all headers and data, then does an audit and modifies the data and only then it forwards to the original response.
But the lambda added in that PR breaks this logic, since the target function writes directly to the original response.

…et function

The PR emicklei#478 brought some weird changes that breaks the filters behaviour.
We have a filter that creates another instance of Response to intercept all headers and data, then does an audit and modifies the data and only then it forwards to the original response.
But the lambda added in that PR breaks this logic, since the target function writes directly to the original response.
@SVilgelm
Copy link
Contributor Author

@emicklei Could you please check this PR? It is a blocker for us

@emicklei
Copy link
Owner

weird I agree , the code in v3 already has this change, see:

Target: func(req *Request, resp *Response) {

@SVilgelm
Copy link
Contributor Author

Yes and I remove that code from v3.

@emicklei
Copy link
Owner

hmm , ic, but I was introduced for another reason. I will have to find that other issue.

@emicklei
Copy link
Owner

Apparently, in #478, @erraggy made that change.

@SVilgelm
Copy link
Contributor Author

yes, I saw both PRs but didn't find any reason for this change.
It really breaks the filters logic.
It is pretty common when we modify/create response or even request in a middleware and the pass new instances to next middleware or to a handler.

@SVilgelm
Copy link
Contributor Author

it is very useful if we have a lot of old legacy handlers, but we need to migrate for new api, then we can intercept the response from handler and convert it into new format

@SVilgelm
Copy link
Contributor Author

@erraggy Could you please check this PR and discussion? Is there a reason of adding lambda and passing original request and response to target instead of the instances that came from filters?

@erraggy
Copy link
Contributor

erraggy commented Nov 24, 2021

Yikes! It appears that my change to container.go was originally based on a 3 year old version of this repo from before this commit: 722f7c5

My change unintentionally brought back this lambda from 3 years ago. Sorry about that.

@SVilgelm
Copy link
Contributor Author

so, then lets merge this PR 😃

@emicklei emicklei merged commit 893c4e1 into emicklei:v3 Nov 24, 2021
@SVilgelm SVilgelm deleted the remove-lambda branch November 24, 2021 19:22
@SVilgelm
Copy link
Contributor Author

cool, thank you very much. Now lets release it as 3.7.2 😺

@SVilgelm
Copy link
Contributor Author

@emicklei do we need to back port it to v2 branch?

@erraggy
Copy link
Contributor

erraggy commented Nov 29, 2021

@emicklei do we need to back port it to v2 branch?

My changes that introduced the bug were only applied to the v3 so I don't think any back-porting would be needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants