Repository navigation
fix(middleware): apply the custom response modifier and refresh stale docs - #43
Merged
Merged
Conversation
… docs The adapter now runs Engine.ModifyResponse last when CustomResponseModifier is configured, then re-applies CORS, matching the reference process_response. The app ErrorHandler runs before the status is read, so handler errors and unrouted requests are recorded with their real status instead of 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 #42
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 #42
I wired
Engine.ModifyResponseinto the pass-through path in the order the reference applies it (security headers, CORS, modifier, then CORS again). The appErrorHandlernow runs before the status is read (the pattern Fiber's logger middleware uses), so handler errors and unrouted requests are recorded as 500 and 404 instead of the unwritten default 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, with a test pinning the header claim.With a modifier configured the adapter rewrites the buffered fasthttp response after the chain. I added real-framework tests that fail on master (modifier ignored, modifier not seeing CORS, error and 404 statuses recorded as 200) 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.