Repository navigation
fix(middleware): apply the custom response modifier and refresh stale docs - #42
Merged
Merged
Conversation
… docs The adapter now holds the handler response when CustomResponseModifier is configured and runs Engine.ModifyResponse last, then re-applies CORS, matching the reference process_response. The status handed to ProcessResponse comes from Writer.Status(), so a handler that only calls c.Status(500) is no longer recorded as 200. The examples and docs no longer tell users to mirror the default address-header exclusion or to avoid EnableAgent: the current engine covers the headers by default and EnableAgent validates. Closes #41
The example Dockerfiles copy the adapter sources by name, so the new modifier.go has to be listed or the image build cannot compile the middleware.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #41
I wired
Engine.ModifyResponseinto the pass-through path in the order the reference applies it (security headers, CORS, modifier, then CORS again), and fixed the status handed toEngine.ProcessResponse: it comes fromc.Writer.Status(), so a handler that only callsc.Status(500)is recorded as 500 instead of 200. I also removed the stale examples and docs claims that the default address headers need a manualExcludedDetectionHeadersentry and thatEnableAgentfails validation; I verified both against the current engine (DefaultExcludedHeaders, andEnableAgentdegrades to agent-off without anAgentHandler), with a test pinning the header claim.With a modifier configured the adapter holds the whole handler response in memory until the handler returns, so streamed responses are delivered at the end. Without a modifier nothing changes. Hijacked connections are left alone. I added real-framework tests that fail on master (modifier ignored, modifier not seeing CORS, wrong status) and pass now, and the repo gate is green: gofmt, vet, staticcheck, unit and integration tests with Redis, and the 100% coverage gate. The engine API used (
ModifyResponse) is already in the released v4.3.2 floor, so no dependency change.I did not change the unknown-client-address behavior: the reference answers 403 "Client address could not be determined" under fail_secure in
handle_passthrough, butEngine.Checkin guard-core-go has no such step (onlyGuardWebSocketdoes), so that fix belongs in the engine.