Skip to content

fix(middleware): apply the custom response modifier and refresh stale docs - #42

Merged
rennf93 merged 2 commits into
masterfrom
parity/adapter-parity
Oct 15, 2026
Merged

rennf93 merged 2 commits into
masterfrom
parity/adapter-parity

Conversation

@rennf93

@rennf93 rennf93 commented Oct 15, 2026

Copy link
Copy Markdown
Member

Closes #41

I wired Engine.ModifyResponse into the pass-through path in the order the reference applies it (security headers, CORS, modifier, then CORS again), and fixed the status handed to Engine.ProcessResponse: it comes from c.Writer.Status(), so a handler that only calls c.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 manual ExcludedDetectionHeaders entry and that EnableAgent fails validation; I verified both against the current engine (DefaultExcludedHeaders, and EnableAgent degrades to agent-off without an AgentHandler), 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, but Engine.Check in guard-core-go has no such step (only GuardWebSocket does), so that fix belongs in the engine.

… 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
@github-actions github-actions Bot added area: middleware Touches the Gin adapter middleware and request shim tests Test suite changes examples Example application changes labels Oct 15, 2026
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.
@rennf93
rennf93 merged commit bd2b11a into master Oct 15, 2026
12 checks passed
@rennf93
rennf93 deleted the parity/adapter-parity branch October 15, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: middleware Touches the Gin adapter middleware and request shim examples Example application changes tests Test suite changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: apply CustomResponseModifier, report the real response status and refresh stale docs

1 participant