Skip to content

Add helpers to instrument existing chi router - #243

Merged
vearutop merged 9 commits into
masterfrom
instrument-chi
Sep 17, 2026
Merged

vearutop merged 9 commits into
masterfrom
instrument-chi

Conversation

@vearutop

Copy link
Copy Markdown
Member

No description provided.

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Go 117 (+2) 9211 (+176) 6605 (+78) 743 (+70) 1863 (+28) 1081 (+7) 228K (+7.5K)
Go (test) 57 (+1) 7316 (+371) 5460 (+143) 481 (+184) 1375 (+44) 200 (+4) 201.2K (+11.8K)
JSON 3 2166 2166 0 0 0 83.1K (-9B)
Makefile 3 127 91 12 24 11 4K (+1B)
Markdown 7 647 (+5) 489 (+4) 0 158 (+1) 0 21.6K (+345B)
YAML 10 668 (-18) 597 (+1) 33 (-13) 38 (-6) 0 19.9K (-832B)

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Go API Changes

# github.com/swaggest/rest/chirouter
## compatible changes
NewOpenAPICollector: added
OpenAPICollector: added
OpenAPIPreparer: added

# github.com/swaggest/rest/gorillamux
## compatible changes
(*OpenAPICollector).Describe: added

# github.com/swaggest/rest/gzip
## compatible changes
JSONContainer.GzipETag: added

# github.com/swaggest/rest/nethttp
## compatible changes
CollectRouteOperation: added
Describe: added
Preparer: added
RoutePreparer: added
RoutePreparerFunc: added

# summary
Inferred base version: v0.2.75
Suggested version: v0.3.0

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Benchmark Result

Benchmark diff with base branch
name                                    old time/op    new time/op    delta
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4    1.32µs ± 0%    1.34µs ± 3%  +1.50%  (p=0.008 n=5+5)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                           677ns ± 0%     684ns ± 1%    ~     (p=0.286 n=4+5)
DecoderFunc_Decode-4                      1.86µs ± 1%    1.88µs ± 5%    ~     (p=0.833 n=5+5)
Decoder_Decode_json-4                     22.5µs ± 1%    22.9µs ± 1%    ~     (p=0.056 n=5+5)
Decoder_Decode_queryObject-4              4.13µs ± 0%    4.16µs ± 1%  +0.65%  (p=0.032 n=5+5)
Decoder_Decode_jsonParam-4                1.38µs ± 2%    1.36µs ± 0%  -1.43%  (p=0.024 n=5+5)
DecoderFactory_SetDecoderFunc-4           1.44µs ± 2%    1.45µs ± 0%    ~     (p=0.135 n=5+5)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                              5.83µs ± 1%    5.92µs ± 0%  +1.46%  (p=0.032 n=5+4)
Middleware_control-4                      2.72µs ± 1%    2.70µs ± 1%    ~     (p=0.206 n=5+5)

name                                    old alloc/op   new alloc/op   delta
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4      681B ± 0%      681B ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                            440B ± 0%      440B ± 0%    ~     (all equal)
DecoderFunc_Decode-4                      1.53kB ± 0%    1.53kB ± 0%    ~     (all equal)
Decoder_Decode_json-4                     10.2kB ± 0%    10.2kB ± 0%    ~     (p=1.000 n=5+5)
Decoder_Decode_queryObject-4              2.01kB ± 0%    2.01kB ± 0%    ~     (all equal)
Decoder_Decode_jsonParam-4                  512B ± 0%      512B ± 0%    ~     (all equal)
DecoderFactory_SetDecoderFunc-4           1.02kB ± 0%    1.02kB ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                              1.16kB ± 2%    1.19kB ± 2%    ~     (p=0.056 n=5+5)
Middleware_control-4                      11.1kB ± 0%    11.1kB ± 0%    ~     (all equal)

name                                    old allocs/op  new allocs/op  delta
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4      11.0 ± 0%      11.0 ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                            4.00 ± 0%      4.00 ± 0%    ~     (all equal)
DecoderFunc_Decode-4                        12.0 ± 0%      12.0 ± 0%    ~     (all equal)
Decoder_Decode_json-4                        181 ± 0%       181 ± 0%    ~     (all equal)
Decoder_Decode_queryObject-4                37.0 ± 0%      37.0 ± 0%    ~     (all equal)
Decoder_Decode_jsonParam-4                  7.00 ± 0%      7.00 ± 0%    ~     (all equal)
DecoderFactory_SetDecoderFunc-4             16.0 ± 0%      16.0 ± 0%    ~     (all equal)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                                11.0 ± 0%      12.0 ± 0%  +9.09%  (p=0.008 n=5+5)
Middleware_control-4                        8.00 ± 0%      8.00 ± 0%    ~     (all equal)
Benchmark result
name                                    time/op
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4  1.34µs ± 3%
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                         684ns ± 1%
DecoderFunc_Decode-4                    1.88µs ± 5%
Decoder_Decode_json-4                   22.9µs ± 1%
Decoder_Decode_queryObject-4            4.16µs ± 1%
Decoder_Decode_jsonParam-4              1.36µs ± 0%
DecoderFactory_SetDecoderFunc-4         1.45µs ± 0%
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                            5.92µs ± 0%
Middleware_control-4                    2.70µs ± 1%

name                                    alloc/op
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4    681B ± 0%
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                          440B ± 0%
DecoderFunc_Decode-4                    1.53kB ± 0%
Decoder_Decode_json-4                   10.2kB ± 0%
Decoder_Decode_queryObject-4            2.01kB ± 0%
Decoder_Decode_jsonParam-4                512B ± 0%
DecoderFactory_SetDecoderFunc-4         1.02kB ± 0%
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                            1.19kB ± 2%
Middleware_control-4                    11.1kB ± 0%

name                                    allocs/op
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-4    11.0 ± 0%
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-4                          4.00 ± 0%
DecoderFunc_Decode-4                      12.0 ± 0%
Decoder_Decode_json-4                      181 ± 0%
Decoder_Decode_queryObject-4              37.0 ± 0%
Decoder_Decode_jsonParam-4                7.00 ± 0%
DecoderFactory_SetDecoderFunc-4           16.0 ± 0%
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-4                              12.0 ± 0%
Middleware_control-4                      8.00 ± 0%

@llamapreview llamapreview Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LlamaPReview — Blocking issues found

Shared func pointers silently attach another route's documentation

Exact-head CI remains unresolved (3 failed); no CI-dependent merge-safety claim is made.

Owner action: State the constraint in the exported docs of RouteDocs and Describe (each documented handler must be a distinct func value; repeated Describe for one key is last-write-wins), or make the registration key unique/detectable, and add a test with two routes whose handlers come from the same literal.

1 further item in details.

Change flow

Registration-time identity keying decides which OpenAPI setup each walked route receives — pointer collisions are the risk point.

sequenceDiagram
participant App as Application
participant Col as OpenAPICollector
participant Map as RouteDocs map
participant Walk as chi.Walk / mux.Walk
participant Prep as RouteDocs.Preparer
participant Doc as OpenAPI document
App->>Col: Describe(h, setup) at registration
Col->>Map: byHandler[ValueOf(h).Pointer()] = setup
note over Col,Map: PR change — identity key is the func code pointer, last write wins
App->>Walk: Walk(router, c.Walker)
Walk->>Prep: Preparer(handler, OperationExtractor)
alt Implements SetupOpenAPIOperation
Prep->>Doc: Use interface setup
else HandlerFunc pointer present in map
Prep->>Doc: Use stored setup for that pointer
else No preparer and no annotation
Prep->>Doc: Emit best-effort Incomplete operation
end
note over Map,Doc: Impact — colliding func values silently attach another route's documentation
Loading
Review details and evidence
Priority File Finding Evidence
P2 nethttp/openapi_router.go Shared func pointers silently attach another route's documentation confirmed
P2 .github/workflows/golangci-lint.yml Lint gate lowered to oldstable and modernize disabled alongside feature needs verification

Finding details

P2 · Lint gate lowered to oldstable and modernize disabled alongside feature

.github/workflows/golangci-lint.yml

The PR lowers the lint workflow from go-version: stable to oldstable and adds modernize to the disabled linters (with action/linter version bumps and a Makefile comment update). Consequence: the lint gate no longer runs on the newest Go release and no longer surfaces modernization findings; if either change was needed to make the new code pass, the findings are suppressed rather than fixed. No product-behavior risk, and the golangci-lint check passes at head — worth splitting out or justifying, not worth blocking.

Owner action: Split the lint-policy loosening into its own PR or justify why oldstable and disabling modernize are needed for this change.

Verification boundary: needs verification; scope: changed region.

LlamaPReview checks

  • Reviewed changed regions in nethttp/openapi_router.go.
  • Reviewed changed regions in chirouter/collector.go.
  • Reviewed changed regions in gorillamux/collector.go.
  • Reviewed changed regions in chirouter/example_openapi_collector_test.go.
  • Read bounded PR-head context from nethttp/openapi_router.go.
  • Reviewed changed regions in .github/workflows/golangci-lint.yml.

LlamaPReview is an open-source pull request reviewer. Tell the maintainers where this review got it wrong.

Comment thread nethttp/openapi_router.go
@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Unit Test Coverage

total: (statements) 81.3%
changed lines: (statements) 59.3%, coverage is less than 90.0%, consider testing the changes more thoroughly

Coverage of changed lines
File Function Coverage
Total 59.3%
chirouter/collector.go 87.5%
chirouter/collector.go:21 NewOpenAPICollector 100.0%
chirouter/collector.go:38 Describe 100.0%
chirouter/collector.go:45 Walker 77.8%
gorillamux/collector.go 100.0%
gorillamux/collector.go:52 Describe 100.0%
gorillamux/collector.go:57 Walker 100.0%
gzip/container.go 86.0%
gzip/container.go:55 PackJSON 100.0%
gzip/container.go:107 GzipETag 100.0%
gzip/container.go:171 JSONWriteTo 100.0%
gzip/container.go:122 marshalJSON 94.9%
gzip/container.go:112 MarshalJSON 0.0%
nethttp/openapi_router.go 0.0%
nethttp/openapi_router.go:38 SetupOpenAPIOperation 0.0%
nethttp/openapi_router.go:50 Describe 0.0%
nethttp/openapi_router.go:56 Preparer 0.0%
nethttp/openapi_router.go:79 CollectRouteOperation 0.0%
response/gzip/middleware.go 100.0%
response/gzip/middleware.go:30 Middleware 100.0%
Coverage diff with base branch

Missing base coverage file

@github-actions

github-actions Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Examples Benchmark Result

Benchmark diff with base branch
name                       old time/op    new time/op    delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                17.8µs ± 1%    18.2µs ± 0%   +2.40%  (p=0.016 n=5+4)
_directGzipHead-4            18.3µs ±12%    18.0µs ± 2%     ~     (p=0.548 n=5+5)
_noDirectGzip-4              82.0µs ± 1%    81.6µs ± 0%   -0.50%  (p=0.016 n=5+5)
_directGzip_decode-4          218µs ± 1%     218µs ± 2%     ~     (p=0.690 n=5+5)
_noDirectGzip_decode-4       82.5µs ± 2%    82.5µs ± 1%     ~     (p=0.690 n=5+5)
_jsonBody-4                  36.5µs ± 0%    37.2µs ± 2%   +1.92%  (p=0.008 n=5+5)
_jsonBodyValidation-4        39.7µs ± 1%    40.4µs ± 2%   +1.75%  (p=0.016 n=5+5)
_outputHeaders-4             18.0µs ± 1%    18.5µs ± 2%   +2.71%  (p=0.008 n=5+5)
_requestResponseMapping-4    31.8µs ± 3%    32.6µs ± 2%     ~     (p=0.056 n=5+5)
_validation-4                36.4µs ± 1%    37.2µs ± 1%   +2.09%  (p=0.008 n=5+5)
_noValidation-4              28.5µs ± 3%    28.7µs ± 1%     ~     (p=0.151 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4           21.5µs ± 1%    21.3µs ± 1%     ~     (p=0.057 n=4+4)
_formOrJSON/json-4           25.2µs ± 1%    25.6µs ± 1%   +1.48%  (p=0.016 n=5+5)
_directGzip-4                18.5µs ± 1%    18.6µs ± 2%     ~     (p=0.841 n=5+5)
_directGzipHead-4            18.2µs ± 2%    18.3µs ± 1%     ~     (p=0.151 n=5+5)
_noDirectGzip-4              82.3µs ± 1%    82.8µs ± 2%     ~     (p=0.841 n=5+5)
_htmlResponse-4              30.9µs ± 0%    31.6µs ± 2%   +2.14%  (p=0.008 n=5+5)
_jsonBodyManual-4            22.7µs ± 1%    23.1µs ± 1%   +2.04%  (p=0.008 n=5+5)
_jsonBody-4                  33.3µs ± 1%    34.2µs ± 2%   +2.92%  (p=0.008 n=5+5)
_jsonBodyValidation-4        40.0µs ± 1%    41.0µs ± 1%   +2.46%  (p=0.008 n=5+5)
_outputHeaders-4             28.6µs ± 2%    29.4µs ± 3%     ~     (p=0.056 n=5+5)
_requestResponseMapping-4    31.6µs ± 1%    32.2µs ± 0%   +1.85%  (p=0.008 n=5+5)
_validation-4                36.4µs ± 1%    36.7µs ± 2%     ~     (p=0.421 n=5+5)
_noValidation-4              28.6µs ± 1%    28.7µs ± 0%     ~     (p=0.690 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4               21.4µs ± 1%    21.5µs ± 0%     ~     (p=0.343 n=4+4)
_ok-4                        21.0µs ± 1%    20.9µs ± 1%     ~     (p=0.421 n=5+5)
_invalidBody-4               30.8µs ± 5%    30.8µs ± 4%     ~     (p=1.000 n=5+5)

name                       old 50%:ms     new 50%:ms     delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                  0.77 ± 4%      0.81 ± 5%     ~     (p=0.095 n=5+5)
_directGzipHead-4              0.78 ±10%      0.78 ± 3%     ~     (p=1.000 n=5+5)
_noDirectGzip-4                3.66 ± 7%      3.73 ± 2%     ~     (p=0.222 n=5+5)
_directGzip_decode-4           5.20 ± 7%      5.39 ±11%     ~     (p=0.548 n=5+5)
_noDirectGzip_decode-4         3.78 ± 2%      3.78 ± 4%     ~     (p=0.841 n=5+5)
_jsonBody-4                    1.55 ± 5%      1.62 ± 5%     ~     (p=0.095 n=5+5)
_jsonBodyValidation-4          1.69 ± 5%      1.78 ± 5%     ~     (p=0.310 n=5+5)
_outputHeaders-4               0.80 ± 6%      0.81 ± 4%     ~     (p=0.690 n=5+5)
_requestResponseMapping-4      1.31 ± 7%      1.33 ±11%     ~     (p=0.968 n=5+5)
_validation-4                  1.53 ± 7%      1.58 ± 7%     ~     (p=0.421 n=5+5)
_noValidation-4                1.15 ± 5%      1.19 ± 5%     ~     (p=0.246 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4             0.91 ± 4%      0.92 ± 6%     ~     (p=1.000 n=5+5)
_formOrJSON/json-4             1.07 ± 4%      1.10 ± 6%     ~     (p=0.310 n=5+5)
_directGzip-4                  0.77 ± 1%      0.82 ± 8%   +5.92%  (p=0.032 n=4+5)
_directGzipHead-4              0.81 ± 5%      0.78 ± 4%     ~     (p=0.056 n=5+5)
_noDirectGzip-4                3.78 ± 5%      3.69 ± 7%     ~     (p=0.222 n=5+5)
_htmlResponse-4                1.29 ± 3%      1.28 ± 3%     ~     (p=0.690 n=5+5)
_jsonBodyManual-4              0.98 ± 1%      0.98 ± 4%     ~     (p=0.841 n=5+5)
_jsonBody-4                    1.41 ± 6%      1.38 ± 3%     ~     (p=0.690 n=5+5)
_jsonBodyValidation-4          1.65 ± 4%      1.73 ± 3%   +4.98%  (p=0.016 n=5+5)
_outputHeaders-4               1.21 ± 5%      1.23 ± 6%     ~     (p=0.690 n=5+5)
_requestResponseMapping-4      1.31 ± 3%      1.34 ± 5%     ~     (p=0.278 n=5+5)
_validation-4                  1.51 ± 5%      1.49 ± 4%     ~     (p=0.690 n=5+5)
_noValidation-4                1.20 ± 3%      1.23 ± 7%     ~     (p=0.310 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 0.94 ± 5%      0.92 ±10%     ~     (p=0.841 n=5+5)
_ok-4                          0.91 ± 4%      0.88 ± 4%     ~     (p=0.056 n=5+5)
_invalidBody-4                 1.33 ± 8%      1.34 ± 6%     ~     (p=0.841 n=5+5)

name                       old 90%:ms     new 90%:ms     delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                  1.61 ± 4%      1.68 ±10%     ~     (p=0.421 n=5+5)
_directGzipHead-4              1.61 ± 2%      1.65 ± 6%     ~     (p=0.556 n=4+5)
_noDirectGzip-4                7.67 ± 6%      7.57 ± 4%     ~     (p=0.595 n=5+5)
_directGzip_decode-4           22.1 ± 4%      22.6 ± 3%     ~     (p=0.421 n=5+5)
_noDirectGzip_decode-4         7.57 ± 5%      7.70 ± 2%     ~     (p=0.222 n=5+5)
_jsonBody-4                    3.31 ± 4%      3.38 ± 3%     ~     (p=0.310 n=5+5)
_jsonBodyValidation-4          3.70 ± 3%      3.77 ± 5%     ~     (p=0.421 n=5+5)
_outputHeaders-4               1.59 ± 4%      1.64 ± 4%     ~     (p=0.222 n=5+5)
_requestResponseMapping-4      2.99 ± 5%      3.05 ± 5%     ~     (p=0.548 n=5+5)
_validation-4                  3.39 ± 4%      3.41 ± 4%     ~     (p=1.000 n=5+5)
_noValidation-4                2.62 ± 3%      2.68 ± 6%     ~     (p=0.548 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4             2.02 ±12%      2.03 ± 4%     ~     (p=0.548 n=5+5)
_formOrJSON/json-4             2.26 ± 4%      2.32 ± 3%     ~     (p=0.222 n=5+5)
_directGzip-4                  1.66 ± 7%      1.69 ± 5%     ~     (p=0.095 n=5+5)
_directGzipHead-4              1.62 ± 2%      1.64 ± 1%     ~     (p=0.095 n=5+5)
_noDirectGzip-4                7.54 ± 2%      7.71 ± 4%     ~     (p=0.548 n=5+5)
_htmlResponse-4                2.93 ± 4%      3.03 ± 3%     ~     (p=0.095 n=5+5)
_jsonBodyManual-4              2.00 ± 3%      2.03 ± 5%     ~     (p=0.579 n=5+5)
_jsonBody-4                    3.04 ± 4%      3.19 ± 6%     ~     (p=0.095 n=5+5)
_jsonBodyValidation-4          3.75 ± 3%      3.77 ± 4%     ~     (p=0.690 n=5+5)
_outputHeaders-4               2.69 ± 7%      2.73 ± 6%     ~     (p=0.937 n=5+5)
_requestResponseMapping-4      2.95 ± 4%      2.99 ± 8%     ~     (p=0.690 n=5+5)
_validation-4                  3.36 ± 4%      3.51 ± 3%     ~     (p=0.095 n=5+5)
_noValidation-4                2.68 ± 2%      2.71 ± 5%     ~     (p=0.881 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 1.94 ± 6%      1.96 ±13%     ~     (p=0.841 n=5+5)
_ok-4                          1.88 ± 3%      1.87 ± 3%     ~     (p=0.841 n=5+5)
_invalidBody-4                 2.87 ± 9%      2.95 ±16%     ~     (p=0.548 n=5+5)

name                       old 99%:ms     new 99%:ms     delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                  2.67 ± 6%      2.79 ± 3%     ~     (p=0.111 n=5+4)
_directGzipHead-4              3.33 ±50%      2.70 ± 8%     ~     (p=0.310 n=5+5)
_noDirectGzip-4                11.9 ± 5%      11.7 ± 3%     ~     (p=0.690 n=5+5)
_directGzip_decode-4           43.8 ±11%      44.1 ± 6%     ~     (p=0.690 n=5+5)
_noDirectGzip_decode-4         11.7 ± 3%      11.6 ± 6%     ~     (p=0.738 n=5+5)
_jsonBody-4                    5.56 ± 4%      5.40 ± 6%     ~     (p=0.310 n=5+5)
_jsonBodyValidation-4          6.02 ± 2%      5.95 ± 5%     ~     (p=0.333 n=5+5)
_outputHeaders-4               2.96 ± 4%      3.00 ± 7%     ~     (p=0.841 n=5+5)
_requestResponseMapping-4      5.21 ±11%      5.35 ± 4%     ~     (p=0.222 n=5+5)
_validation-4                  5.73 ± 4%      5.85 ± 8%     ~     (p=0.310 n=5+5)
_noValidation-4                4.71 ±13%      4.66 ± 5%     ~     (p=0.841 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4             3.23 ± 1%      3.49 ±40%     ~     (p=0.730 n=4+5)
_formOrJSON/json-4             3.80 ± 7%      4.02 ± 3%     ~     (p=0.056 n=5+5)
_directGzip-4                  2.91 ± 6%      2.91 ±10%     ~     (p=0.968 n=5+5)
_directGzipHead-4              2.78 ±11%      2.83 ± 5%     ~     (p=0.310 n=5+5)
_noDirectGzip-4                11.4 ± 5%      12.0 ±15%     ~     (p=0.421 n=5+5)
_htmlResponse-4                4.90 ± 5%      5.16 ± 5%     ~     (p=0.056 n=5+5)
_jsonBodyManual-4              3.90 ± 8%      3.79 ± 5%     ~     (p=0.548 n=5+5)
_jsonBody-4                    5.35 ± 9%      5.55 ± 8%     ~     (p=0.421 n=5+5)
_jsonBodyValidation-4          5.92 ± 4%      6.08 ± 3%     ~     (p=0.151 n=5+5)
_outputHeaders-4               4.58 ± 3%      4.78 ±12%     ~     (p=0.421 n=5+5)
_requestResponseMapping-4      4.77 ± 4%      5.03 ± 4%     ~     (p=0.056 n=5+5)
_validation-4                  5.67 ± 5%      5.63 ± 5%     ~     (p=0.841 n=5+5)
_noValidation-4                4.65 ± 5%      4.56 ± 7%     ~     (p=0.690 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 3.42 ±32%      3.15 ± 2%     ~     (p=0.730 n=5+4)
_ok-4                          3.19 ± 5%      3.06 ± 2%     ~     (p=0.056 n=5+5)
_invalidBody-4                 5.16 ± 7%      5.08 ± 4%     ~     (p=0.421 n=5+5)

name                       old 99.9%:ms   new 99.9%:ms   delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                  4.36 ±18%      4.80 ±46%     ~     (p=0.690 n=5+5)
_directGzipHead-4              5.85 ±69%      4.21 ±10%     ~     (p=0.222 n=5+5)
_noDirectGzip-4                17.2 ±20%      16.1 ± 9%     ~     (p=0.548 n=5+5)
_directGzip_decode-4           66.2 ± 9%      64.8 ± 4%     ~     (p=0.548 n=5+5)
_noDirectGzip_decode-4         17.2 ±19%      15.9 ±13%     ~     (p=0.548 n=5+5)
_jsonBody-4                    7.97 ± 9%      7.89 ±12%     ~     (p=0.841 n=5+5)
_jsonBodyValidation-4          8.87 ±10%      8.29 ± 8%     ~     (p=0.222 n=5+5)
_outputHeaders-4               4.96 ±10%      5.00 ± 8%     ~     (p=0.841 n=5+5)
_requestResponseMapping-4      7.93 ±18%      8.05 ±11%     ~     (p=1.000 n=5+5)
_validation-4                  7.94 ± 7%      8.62 ± 5%   +8.57%  (p=0.016 n=5+5)
_noValidation-4                6.95 ±15%      6.91 ± 9%     ~     (p=0.841 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4             5.28 ±52%      5.01 ±37%     ~     (p=0.841 n=5+5)
_formOrJSON/json-4             6.35 ±17%      6.85 ±27%     ~     (p=0.421 n=5+5)
_directGzip-4                  4.69 ±13%      4.37 ±16%     ~     (p=0.548 n=5+5)
_directGzipHead-4              4.47 ±11%      4.56 ±14%     ~     (p=0.690 n=5+5)
_noDirectGzip-4                15.7 ± 9%      19.2 ±15%  +21.88%  (p=0.032 n=5+5)
_htmlResponse-4                7.43 ± 8%      7.32 ± 8%     ~     (p=0.690 n=5+5)
_jsonBodyManual-4              6.07 ±11%      6.03 ± 7%     ~     (p=1.000 n=5+5)
_jsonBody-4                    7.65 ±17%      7.92 ±13%     ~     (p=0.690 n=5+5)
_jsonBodyValidation-4          8.01 ±10%      8.65 ± 5%     ~     (p=0.151 n=5+5)
_outputHeaders-4               6.77 ±11%      7.40 ±22%     ~     (p=0.222 n=5+5)
_requestResponseMapping-4      6.63 ± 5%      7.38 ± 8%  +11.24%  (p=0.008 n=5+5)
_validation-4                  8.24 ±18%      8.34 ±11%     ~     (p=0.841 n=5+5)
_noValidation-4                6.84 ±15%      6.74 ±24%     ~     (p=0.548 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 5.30 ±18%      5.44 ±37%     ~     (p=1.000 n=5+5)
_ok-4                          5.15 ±10%      4.69 ±13%     ~     (p=0.222 n=5+5)
_invalidBody-4                 7.07 ±14%      7.28 ± 8%     ~     (p=0.548 n=5+5)

name                       old B:rcvd/op  new B:rcvd/op  delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                   645 ± 0%       668 ± 0%   +3.57%  (p=0.008 n=5+5)
_directGzipHead-4               175 ± 0%       198 ± 0%  +13.14%  (p=0.008 n=5+5)
_noDirectGzip-4                 652 ± 0%       675 ± 0%   +3.53%  (p=0.008 n=5+5)
_directGzip_decode-4            645 ± 0%       668 ± 0%   +3.57%  (p=0.008 n=5+5)
_noDirectGzip_decode-4          652 ± 0%       675 ± 0%   +3.53%  (p=0.008 n=5+5)
_jsonBody-4                     199 ± 0%       222 ± 0%  +11.56%  (p=0.008 n=5+5)
_jsonBodyValidation-4           185 ± 0%       208 ± 0%  +12.43%  (p=0.008 n=5+5)
_outputHeaders-4                146 ± 0%       169 ± 0%  +15.75%  (p=0.008 n=5+5)
_requestResponseMapping-4      94.0 ± 0%     117.0 ± 0%  +24.47%  (p=0.008 n=5+5)
_validation-4                   168 ± 0%       191 ± 0%  +13.69%  (p=0.008 n=5+5)
_noValidation-4                 168 ± 0%       191 ± 0%  +13.69%  (p=0.008 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4              155 ± 0%       178 ± 0%  +14.84%  (p=0.008 n=5+5)
_formOrJSON/json-4              156 ± 0%       179 ± 0%  +14.74%  (p=0.008 n=5+5)
_directGzip-4                   653 ± 0%       676 ± 0%   +3.52%  (p=0.008 n=5+5)
_directGzipHead-4               183 ± 0%       206 ± 0%  +12.57%  (p=0.008 n=5+5)
_noDirectGzip-4                 660 ± 0%       683 ± 0%   +3.48%  (p=0.008 n=5+5)
_htmlResponse-4                 355 ± 0%       378 ± 0%   +6.48%  (p=0.008 n=5+5)
_jsonBodyManual-4               207 ± 0%       230 ± 0%  +11.11%  (p=0.008 n=5+5)
_jsonBody-4                     207 ± 0%       230 ± 0%  +11.11%  (p=0.008 n=5+5)
_jsonBodyValidation-4           193 ± 0%       216 ± 0%  +11.92%  (p=0.008 n=5+5)
_outputHeaders-4                214 ± 0%       237 ± 0%  +10.75%  (p=0.008 n=5+5)
_requestResponseMapping-4       108 ± 0%       131 ± 0%  +21.30%  (p=0.008 n=5+5)
_validation-4                   176 ± 0%       199 ± 0%  +13.07%  (p=0.008 n=5+5)
_noValidation-4                 176 ± 0%       199 ± 0%  +13.07%  (p=0.008 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                  322 ± 0%       322 ± 0%     ~     (all equal)
_ok-4                           344 ± 0%       344 ± 0%     ~     (all equal)
_invalidBody-4                  420 ± 0%       420 ± 0%     ~     (all equal)

name                       old B:sent/op  new B:sent/op  delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                   103 ± 0%       103 ± 0%     ~     (all equal)
_directGzipHead-4               104 ± 0%       104 ± 0%     ~     (all equal)
_noDirectGzip-4                 117 ± 0%       117 ± 0%     ~     (all equal)
_directGzip_decode-4            116 ± 0%       116 ± 0%     ~     (all equal)
_noDirectGzip_decode-4          130 ± 0%       130 ± 0%     ~     (all equal)
_jsonBody-4                     188 ± 0%       188 ± 0%     ~     (all equal)
_jsonBodyValidation-4           192 ± 0%       192 ± 0%     ~     (all equal)
_outputHeaders-4               77.0 ± 0%      77.0 ± 0%     ~     (all equal)
_requestResponseMapping-4       169 ± 0%       169 ± 0%     ~     (all equal)
_validation-4                   170 ± 0%       170 ± 0%     ~     (all equal)
_noValidation-4                 173 ± 0%       173 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4              170 ± 0%       170 ± 0%     ~     (all equal)
_formOrJSON/json-4              162 ± 0%       162 ± 0%     ~     (all equal)
_directGzip-4                   103 ± 0%       103 ± 0%     ~     (all equal)
_directGzipHead-4               104 ± 0%       104 ± 0%     ~     (all equal)
_noDirectGzip-4                 117 ± 0%       117 ± 0%     ~     (all equal)
_htmlResponse-4                 108 ± 0%       108 ± 0%     ~     (all equal)
_jsonBodyManual-4               195 ± 0%       195 ± 0%     ~     (all equal)
_jsonBody-4                     188 ± 0%       188 ± 0%     ~     (all equal)
_jsonBodyValidation-4           192 ± 0%       192 ± 0%     ~     (all equal)
_outputHeaders-4               88.0 ± 0%      88.0 ± 0%     ~     (all equal)
_requestResponseMapping-4       169 ± 0%       169 ± 0%     ~     (all equal)
_validation-4                   170 ± 0%       170 ± 0%     ~     (all equal)
_noValidation-4                 173 ± 0%       173 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 74.0 ± 0%      74.0 ± 0%     ~     (all equal)
_ok-4                          74.0 ± 0%      74.0 ± 0%     ~     (all equal)
_invalidBody-4                  137 ± 0%       137 ± 0%     ~     (all equal)

name                       old rps        new rps        delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                 56.2k ± 1%     54.8k ± 0%   -2.38%  (p=0.016 n=5+4)
_directGzipHead-4             54.8k ±11%     55.4k ± 2%     ~     (p=0.548 n=5+5)
_noDirectGzip-4               12.2k ± 1%     12.3k ± 0%   +0.50%  (p=0.016 n=5+5)
_directGzip_decode-4          4.59k ± 1%     4.58k ± 2%     ~     (p=0.690 n=5+5)
_noDirectGzip_decode-4        12.1k ± 1%     12.1k ± 1%     ~     (p=0.690 n=5+5)
_jsonBody-4                   27.4k ± 0%     26.9k ± 2%   -1.88%  (p=0.008 n=5+5)
_jsonBodyValidation-4         25.2k ± 1%     24.8k ± 2%   -1.71%  (p=0.016 n=5+5)
_outputHeaders-4              55.5k ± 1%     54.0k ± 2%   -2.63%  (p=0.008 n=5+5)
_requestResponseMapping-4     31.5k ± 3%     30.6k ± 2%     ~     (p=0.056 n=5+5)
_validation-4                 27.5k ± 1%     26.9k ± 1%   -2.05%  (p=0.008 n=5+5)
_noValidation-4               35.1k ± 3%     34.8k ± 1%     ~     (p=0.151 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4            46.5k ± 1%     46.9k ± 1%     ~     (p=0.057 n=4+4)
_formOrJSON/json-4            39.6k ± 1%     39.1k ± 1%   -1.46%  (p=0.016 n=5+5)
_directGzip-4                 54.0k ± 2%     53.8k ± 2%     ~     (p=0.841 n=5+5)
_directGzipHead-4             55.0k ± 2%     54.8k ± 1%     ~     (p=0.151 n=5+5)
_noDirectGzip-4               12.1k ± 1%     12.1k ± 2%     ~     (p=0.841 n=5+5)
_htmlResponse-4               32.4k ± 0%     31.7k ± 2%   -2.08%  (p=0.008 n=5+5)
_jsonBodyManual-4             44.1k ± 1%     43.2k ± 1%   -2.01%  (p=0.008 n=5+5)
_jsonBody-4                   30.1k ± 1%     29.2k ± 2%   -2.82%  (p=0.008 n=5+5)
_jsonBodyValidation-4         25.0k ± 1%     24.4k ± 1%   -2.40%  (p=0.008 n=5+5)
_outputHeaders-4              35.0k ± 2%     34.0k ± 3%     ~     (p=0.056 n=5+5)
_requestResponseMapping-4     31.6k ± 1%     31.0k ± 0%   -1.82%  (p=0.008 n=5+5)
_validation-4                 27.4k ± 1%     27.2k ± 3%     ~     (p=0.421 n=5+5)
_noValidation-4               34.9k ± 1%     34.8k ± 0%     ~     (p=0.690 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                46.6k ± 1%     46.5k ± 0%     ~     (p=0.343 n=4+4)
_ok-4                         47.6k ± 1%     47.9k ± 1%     ~     (p=0.421 n=5+5)
_invalidBody-4                32.5k ± 4%     32.5k ± 4%     ~     (p=1.000 n=5+5)

name                       old alloc/op   new alloc/op   delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                3.94kB ± 0%    4.01kB ± 0%   +1.68%  (p=0.008 n=5+5)
_directGzipHead-4            3.94kB ± 0%    4.00kB ± 0%   +1.62%  (p=0.008 n=5+5)
_noDirectGzip-4              6.64kB ± 3%    6.55kB ± 6%     ~     (p=0.841 n=5+5)
_directGzip_decode-4          330kB ± 0%     330kB ± 0%     ~     (p=0.841 n=5+5)
_noDirectGzip_decode-4       6.39kB ± 6%    6.47kB ± 3%     ~     (p=0.937 n=5+5)
_jsonBody-4                  9.44kB ± 0%    9.47kB ± 0%   +0.34%  (p=0.008 n=5+5)
_jsonBodyValidation-4        11.5kB ± 0%    11.5kB ± 0%   +0.24%  (p=0.008 n=5+5)
_outputHeaders-4             3.61kB ± 0%    3.64kB ± 0%   +0.86%  (p=0.008 n=5+5)
_requestResponseMapping-4    9.38kB ± 0%    9.42kB ± 0%   +0.41%  (p=0.008 n=5+5)
_validation-4                10.3kB ± 0%    10.4kB ± 0%   +0.34%  (p=0.008 n=5+5)
_noValidation-4              7.03kB ± 0%    7.06kB ± 0%   +0.42%  (p=0.008 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4           6.14kB ± 0%    6.18kB ± 0%   +0.79%  (p=0.008 n=5+5)
_formOrJSON/json-4           5.83kB ± 0%    5.88kB ± 0%   +0.86%  (p=0.008 n=5+5)
_directGzip-4                3.95kB ± 0%    4.04kB ± 0%   +2.10%  (p=0.029 n=4+4)
_directGzipHead-4            3.95kB ± 0%    4.03kB ± 0%   +2.01%  (p=0.008 n=5+5)
_noDirectGzip-4              6.59kB ± 9%    6.50kB ± 8%     ~     (p=0.690 n=5+5)
_htmlResponse-4              8.07kB ± 0%    8.12kB ± 0%   +0.64%  (p=0.008 n=5+5)
_jsonBodyManual-4            4.67kB ± 0%    4.71kB ± 0%   +1.02%  (p=0.008 n=5+5)
_jsonBody-4                  8.15kB ± 0%    8.20kB ± 0%   +0.63%  (p=0.008 n=5+5)
_jsonBodyValidation-4        11.5kB ± 0%    11.6kB ± 0%   +0.45%  (p=0.008 n=5+5)
_outputHeaders-4             6.73kB ± 0%    6.78kB ± 0%   +0.75%  (p=0.008 n=5+5)
_requestResponseMapping-4    9.42kB ± 0%    9.47kB ± 0%   +0.57%  (p=0.008 n=5+5)
_validation-4                10.4kB ± 0%    10.4kB ± 0%   +0.39%  (p=0.008 n=5+5)
_noValidation-4              7.08kB ± 0%    7.12kB ± 0%   +0.59%  (p=0.008 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4               5.29kB ± 0%    5.29kB ± 0%     ~     (p=0.976 n=5+5)
_ok-4                        5.07kB ± 0%    5.07kB ± 0%     ~     (p=1.000 n=4+5)
_invalidBody-4               8.19kB ± 0%    8.19kB ± 0%     ~     (p=0.886 n=4+4)

name                       old allocs/op  new allocs/op  delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-4                  42.0 ± 0%      44.0 ± 0%   +4.76%  (p=0.008 n=5+5)
_directGzipHead-4              42.0 ± 0%      44.0 ± 0%   +4.76%  (p=0.008 n=5+5)
_noDirectGzip-4                49.0 ± 0%      50.0 ± 0%   +2.04%  (p=0.008 n=5+5)
_directGzip_decode-4           85.6 ± 2%      87.6 ± 1%   +2.34%  (p=0.024 n=5+5)
_noDirectGzip_decode-4         51.0 ± 0%      52.0 ± 0%   +1.96%  (p=0.008 n=5+5)
_jsonBody-4                     139 ± 0%       140 ± 0%   +0.72%  (p=0.008 n=5+5)
_jsonBodyValidation-4           204 ± 0%       205 ± 0%   +0.49%  (p=0.008 n=5+5)
_outputHeaders-4               35.0 ± 0%      36.0 ± 0%   +2.86%  (p=0.008 n=5+5)
_requestResponseMapping-4       138 ± 0%       139 ± 0%   +0.72%  (p=0.008 n=5+5)
_validation-4                   164 ± 0%       165 ± 0%   +0.61%  (p=0.008 n=5+5)
_noValidation-4                88.0 ± 0%      89.0 ± 0%   +1.14%  (p=0.008 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic-openapi31 goos:linux goarch:amd64
_formOrJSON/form-4             58.0 ± 0%      59.0 ± 0%   +1.72%  (p=0.008 n=5+5)
_formOrJSON/json-4             68.0 ± 0%      69.0 ± 0%   +1.47%  (p=0.008 n=5+5)
_directGzip-4                  43.0 ± 0%      45.0 ± 0%   +4.65%  (p=0.029 n=4+4)
_directGzipHead-4              43.0 ± 0%      45.0 ± 0%   +4.65%  (p=0.008 n=5+5)
_noDirectGzip-4                50.0 ± 0%      51.0 ± 0%   +2.00%  (p=0.008 n=5+5)
_htmlResponse-4                 124 ± 0%       125 ± 0%   +0.81%  (p=0.008 n=5+5)
_jsonBodyManual-4              44.0 ± 0%      45.0 ± 0%   +2.27%  (p=0.008 n=5+5)
_jsonBody-4                     106 ± 0%       107 ± 0%   +0.94%  (p=0.008 n=5+5)
_jsonBodyValidation-4           205 ± 0%       206 ± 0%   +0.49%  (p=0.008 n=5+5)
_outputHeaders-4                121 ± 0%       122 ± 0%   +0.83%  (p=0.008 n=5+5)
_requestResponseMapping-4       139 ± 0%       140 ± 0%   +0.72%  (p=0.008 n=5+5)
_validation-4                   165 ± 0%       166 ± 0%   +0.61%  (p=0.008 n=5+5)
_noValidation-4                89.0 ± 0%      90.0 ± 0%   +1.12%  (p=0.008 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-4                 54.0 ± 0%      54.0 ± 0%     ~     (all equal)
_ok-4                          48.0 ± 0%      48.0 ± 0%     ~     (all equal)
_invalidBody-4                  102 ± 0%       102 ± 0%     ~     (all equal)

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Resolve the critical gzip ETag representation and Accept-Encoding caching issue.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds reusable OpenAPI instrumentation helpers for existing Chi and Gorilla/Mux routers, alongside gzip ETag, dependency, and tooling updates.

Changes:

  • Adds shared route description and collection helpers.
  • Adds Chi and Gorilla/Mux integrations and examples.
  • Updates gzip ETag handling and expectations.
  • Updates dependencies, linting, CI, and generated fixtures.
  • Critical: gzip and identity responses may share strong ETags without Vary: Accept-Encoding.
File summaries
File Summary
README.md Documents router integrations.
nethttp/openapi_router.go Adds shared OpenAPI helpers.
Makefile Updates lint tooling.
gzip/container.go Changes gzip ETag hashing.
gzip/container_test.go Updates ETag tests.
gorillamux/example_openapi_collector_test.go Adds Gorilla/Mux usage example.
gorillamux/collector.go Uses shared route helpers.
go.sum Updates dependency checksums.
go.mod Updates dependencies.
chirouter/example_openapi_collector_test.go Adds Chi usage example.
chirouter/collector.go Adds Chi route collection.
.golangci.yml Updates lint configuration.
.github/workflows/golangci-lint.yml Updates lint CI configuration.
_examples/go.sum Updates example checksums.
_examples/go.mod Updates example dependencies.
_examples/advanced/gzip_pass_through_test.go Updates gzip expectations.
_examples/advanced-generic-openapi31/gzip_pass_through_test.go Updates gzip expectations.
_examples/advanced-generic-openapi31/_testdata/openapi.json Updates generated OpenAPI fixture.
Review details
  • Files reviewed: 16/18 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread gzip/container.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Gzip ETag handling needs correction for cache variation, exact compressed bytes, application validators, and actual compression state.

Get a fresh assessment by requesting another Copilot review.

Review details

Suppressed comments (3)

gzip/container.go:106

  • GzipETag is not a validator for the gzip representation: it hashes the uncompressed JSON plus a fixed salt, while the bytes served by WriteCompressedBytes are the gzip output. A change in flate settings or Go's gzip implementation can therefore leave this strong ETag unchanged while changing the response bytes. Compute the validator from the exact compressed bytes (or mark it weak/content-equivalence and adjust conditional-cache semantics) instead of salting the identity digest.
// GzipETag returns a hash of uncompressed JSON content salted for the gzip-compressed
// representation, so it differs from ETag.
//
// The gzip and identity representations are byte-distinct, so gzip-compression middleware
// (see response/gzip) uses this instead of ETag when serving the gzip body, to avoid one
// strong validator being shared between two different representations.

gzip/container.go:180

  • This replaces any pre-existing ETag whenever the response writer supports direct gzip output, even when that ETag was deliberately supplied by the application rather than generated from JSONContainer.ETag(). That silently changes the resource's validator only for gzip-capable requests. Restrict the swap to the identity ETag generated for this container (or otherwise preserve application-provided validators).
	if rw, ok := w.(http.ResponseWriter); ok {
		if _, ok := w.(Writer); ok && rw.Header().Get("Etag") != "" {
			rw.Header().Set("Etag", jc.gzipHash)
		}

gzip/container.go:179

  • JSONWriteTo selects gzipHash solely from the writer implementing Writer, but gzipResponseWriter implements Writer even when writeHeader later disables compression for a non-compressible Content-Type (for example text/csv or application/octet-stream). In that case the body is identity-encoded while it carries the gzip representation's ETag. Select the validator only after the middleware has decided the actual representation, or otherwise gate this swap on the same compression decision.
	if rw, ok := w.(http.ResponseWriter); ok {
		if _, ok := w.(Writer); ok && rw.Header().Get("Etag") != "" {
			rw.Header().Set("Etag", jc.gzipHash)
  • Files reviewed: 16/18 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment thread gzip/container.go

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The changed routing and gzip behavior is covered by examples and focused tests, with no unresolved correctness issues identified.

Review details
  • Files reviewed: 18/20 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

@vearutop
vearutop merged commit 7ab8be3 into master Sep 17, 2026
9 checks passed
@vearutop
vearutop deleted the instrument-chi branch September 17, 2026 21:29
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.

2 participants