swaggest / rest

Web services with OpenAPI and JSON Schema done quick in Go
https://pkg.go.dev/github.com/swaggest/rest
MIT License
362 stars 17 forks source link

Fix handling of deeply embedded writer together with headers #105

Closed vearutop closed 1 year ago

vearutop commented 1 year ago
type generateLinksOutput struct {
    usecase.OutputWithEmbeddedWriter

    ContentDisposition string `header:"Content-Disposition"`
}

// GenerateLinksForm creates use case interactor.
func GenerateLinksForm(base usecase.IOInteractorOf[generateLinksInput, generatedLinks]) usecase.Interactor {
    u := usecase.NewInteractor(func(ctx context.Context, in generateLinksFormInput, out *generateLinksOutput) error {
        out.ContentDisposition = "attachment; filename=\"links.csv\""

This would panic

 panic: reflect.Value.Interface: cannot return value obtained from unexported field or method

 -> reflect.valueInterface
 ->   /usr/local/opt/go/libexec/src/reflect/value.go:1489

    reflect.Value.Interface
      /usr/local/opt/go/libexec/src/reflect/value.go:1478
    github.com/swaggest/form/v5.(*encoder).setFieldByType
      /Users/vearutop/go/pkg/mod/github.com/swaggest/form/v5@v5.0.1/encoder.go:123
    github.com/swaggest/form/v5.(*encoder).traverseStruct
      /Users/vearutop/go/pkg/mod/github.com/swaggest/form/v5@v5.0.1/encoder.go:60
    github.com/swaggest/form/v5.(*encoder).setFieldByType
      /Users/vearutop/go/pkg/mod/github.com/swaggest/form/v5@v5.0.1/encoder.go:233
...
github-actions[bot] commented 1 year ago

Lines Of Code

Language Files Lines Code Comments Blanks Complexity Bytes
Go 104 7186 (+8) 5214 (+6) 482 1490 (+2) 867 (+1) 173.6K (+171B)
Go (test) 47 4981 3809 182 990 178 138.2K (+24B)
github-actions[bot] commented 1 year ago

Go API Changes

# summary
Inferred base version: v0.2.35
Suggested version: v0.2.36
github-actions[bot] commented 1 year ago

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-2 1.34µs ± 0% 1.35µs ± 1% +1.02% (p=0.016 n=4+5) pkg:github.com/swaggest/rest/request goos:linux goarch:amd64 Decoder_Decode-2 712ns ± 3% 701ns ± 1% ~ (p=0.056 n=5+5) DecoderFunc_Decode-2 2.00µs ± 0% 2.01µs ± 4% ~ (p=0.286 n=4+5) Decoder_Decode_json-2 22.0µs ± 3% 21.8µs ± 1% ~ (p=0.690 n=5+5) Decoder_Decode_queryObject-2 4.64µs ± 0% 4.63µs ± 0% ~ (p=0.222 n=5+5) Decoder_Decode_jsonParam-2 1.78µs ± 0% 1.79µs ± 0% +0.68% (p=0.008 n=5+5) DecoderFactory_SetDecoderFunc-2 1.65µs ± 0% 1.64µs ± 0% -0.53% (p=0.024 n=5+5) pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64 Middleware-2 11.0µs ± 3% 11.0µs ± 1% ~ (p=0.841 n=5+5) Middleware_control-2 3.46µs ± 1% 3.43µs ± 1% ~ (p=0.056 n=5+5) name old alloc/op new alloc/op delta pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64 RequestValidator_ValidateRequestData-2 2.46kB ± 0% 2.46kB ± 0% ~ (all equal) pkg:github.com/swaggest/rest/request goos:linux goarch:amd64 Decoder_Decode-2 440B ± 0% 440B ± 0% ~ (all equal) DecoderFunc_Decode-2 1.51kB ± 0% 1.51kB ± 0% ~ (all equal) Decoder_Decode_json-2 12.2kB ± 0% 12.2kB ± 0% ~ (all equal) Decoder_Decode_queryObject-2 2.00kB ± 0% 2.00kB ± 0% ~ (all equal) Decoder_Decode_jsonParam-2 736B ± 0% 736B ± 0% ~ (all equal) DecoderFactory_SetDecoderFunc-2 1.02kB ± 0% 1.02kB ± 0% ~ (all equal) pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64 Middleware-2 1.16kB ± 4% 1.16kB ± 3% ~ (p=0.786 n=5+5) Middleware_control-2 11.2kB ± 0% 11.2kB ± 0% ~ (all equal) name old allocs/op new allocs/op delta pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64 RequestValidator_ValidateRequestData-2 8.00 ± 0% 8.00 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/request goos:linux goarch:amd64 Decoder_Decode-2 4.00 ± 0% 4.00 ± 0% ~ (all equal) DecoderFunc_Decode-2 12.0 ± 0% 12.0 ± 0% ~ (all equal) Decoder_Decode_json-2 177 ± 0% 177 ± 0% ~ (all equal) Decoder_Decode_queryObject-2 36.0 ± 0% 36.0 ± 0% ~ (all equal) Decoder_Decode_jsonParam-2 13.0 ± 0% 13.0 ± 0% ~ (all equal) DecoderFactory_SetDecoderFunc-2 16.0 ± 0% 16.0 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64 Middleware-2 11.0 ± 0% 11.0 ± 0% ~ (all equal) Middleware_control-2 9.00 ± 0% 9.00 ± 0% ~ (all equal) ```
Benchmark result ``` name time/op pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64 RequestValidator_ValidateRequestData-2 1.35µs ± 1% pkg:github.com/swaggest/rest/request goos:linux goarch:amd64 Decoder_Decode-2 701ns ± 1% DecoderFunc_Decode-2 2.01µs ± 4% Decoder_Decode_json-2 21.8µs ± 1% Decoder_Decode_queryObject-2 4.63µs ± 0% Decoder_Decode_jsonParam-2 1.79µs ± 0% DecoderFactory_SetDecoderFunc-2 1.64µs ± 0% pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64 Middleware-2 11.0µs ± 1% Middleware_control-2 3.43µs ± 1% name alloc/op pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64 RequestValidator_ValidateRequestData-2 2.46kB ± 0% pkg:github.com/swaggest/rest/request goos:linux goarch:amd64 Decoder_Decode-2 440B ± 0% DecoderFunc_Decode-2 1.51kB ± 0% Decoder_Decode_json-2 12.2kB ± 0% Decoder_Decode_queryObject-2 2.00kB ± 0% Decoder_Decode_jsonParam-2 736B ± 0% DecoderFactory_SetDecoderFunc-2 1.02kB ± 0% pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64 Middleware-2 1.16kB ± 3% Middleware_control-2 11.2kB ± 0% name allocs/op pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64 RequestValidator_ValidateRequestData-2 8.00 ± 0% pkg:github.com/swaggest/rest/request goos:linux goarch:amd64 Decoder_Decode-2 4.00 ± 0% DecoderFunc_Decode-2 12.0 ± 0% Decoder_Decode_json-2 177 ± 0% Decoder_Decode_queryObject-2 36.0 ± 0% Decoder_Decode_jsonParam-2 13.0 ± 0% DecoderFactory_SetDecoderFunc-2 16.0 ± 0% pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64 Middleware-2 11.0 ± 0% Middleware_control-2 9.00 ± 0% ```
github-actions[bot] commented 1 year ago

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-2 31.6µs ± 4% 30.8µs ±15% ~ (p=0.222 n=5+5) _directGzipHead-2 30.0µs ± 2% 30.2µs ± 1% ~ (p=0.548 n=5+5) _noDirectGzip-2 157µs ± 4% 159µs ± 4% ~ (p=0.548 n=5+5) _directGzip_decode-2 588µs ± 5% 606µs ± 4% ~ (p=0.222 n=5+5) _noDirectGzip_decode-2 155µs ± 1% 157µs ± 4% ~ (p=0.421 n=5+5) _jsonBody-2 55.8µs ± 6% 55.8µs ± 4% ~ (p=1.000 n=5+5) _jsonBodyValidation-2 65.2µs ± 6% 65.7µs ± 6% ~ (p=0.841 n=5+5) _outputHeaders-2 29.3µs ± 4% 29.4µs ± 7% ~ (p=1.000 n=5+5) _requestResponseMapping-2 54.0µs ± 5% 56.0µs ± 5% ~ (p=0.222 n=5+5) _validation-2 57.4µs ± 4% 58.5µs ± 5% ~ (p=0.095 n=5+5) _noValidation-2 42.4µs ± 4% 43.1µs ± 4% ~ (p=0.548 n=5+5) pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64 _directGzip-2 30.3µs ± 1% 31.4µs ± 4% ~ (p=0.063 n=4+5) _directGzipHead-2 30.2µs ± 2% 32.1µs ±11% +6.40% (p=0.032 n=5+5) _noDirectGzip-2 156µs ± 1% 157µs ± 1% ~ (p=0.151 n=5+5) _directGzip_decode-2 610µs ± 6% 587µs ± 4% ~ (p=0.222 n=5+5) _noDirectGzip_decode-2 159µs ± 3% 156µs ± 1% ~ (p=0.690 n=5+5) _htmlResponse-2 48.5µs ± 6% 49.1µs ± 6% ~ (p=0.841 n=5+5) _jsonBodyManual-2 35.2µs ± 2% 35.9µs ± 3% ~ (p=0.222 n=5+5) _jsonBody-2 50.4µs ± 3% 50.4µs ± 4% ~ (p=1.000 n=5+5) _jsonBodyValidation-2 65.7µs ± 7% 65.1µs ± 7% ~ (p=0.690 n=5+5) _outputHeaders-2 30.2µs ± 7% 30.0µs ± 3% ~ (p=0.841 n=5+5) _requestResponseMapping-2 57.9µs ± 9% 56.4µs ± 4% ~ (p=0.548 n=5+5) _validation-2 62.6µs ± 6% 61.0µs ± 5% ~ (p=0.421 n=5+5) _noValidation-2 43.6µs ± 2% 44.4µs ± 4% ~ (p=0.548 n=5+5) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 35.3µs ±16% 34.1µs ± 9% ~ (p=0.421 n=5+5) _ok-2 34.0µs ± 6% 34.7µs ± 8% ~ (p=0.421 n=5+5) _invalidBody-2 48.1µs ± 2% 48.1µs ± 2% ~ (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-2 1.41 ± 5% 1.38 ± 8% ~ (p=0.310 n=5+5) _directGzipHead-2 1.39 ± 3% 1.43 ± 9% ~ (p=0.421 n=5+5) _noDirectGzip-2 7.59 ± 3% 7.59 ± 8% ~ (p=1.000 n=5+5) _directGzip_decode-2 22.3 ± 7% 24.3 ± 8% ~ (p=0.056 n=5+5) _noDirectGzip_decode-2 7.35 ± 3% 7.62 ± 5% ~ (p=0.310 n=5+5) _jsonBody-2 2.47 ± 6% 2.44 ± 3% ~ (p=0.841 n=5+5) _jsonBodyValidation-2 2.87 ± 4% 2.85 ± 8% ~ (p=0.548 n=5+5) _outputHeaders-2 1.37 ± 7% 1.36 ± 6% ~ (p=1.000 n=5+5) _requestResponseMapping-2 2.32 ± 5% 2.42 ± 6% ~ (p=0.151 n=5+5) _validation-2 2.55 ± 7% 2.57 ± 4% ~ (p=0.690 n=5+5) _noValidation-2 1.83 ± 7% 1.88 ± 2% ~ (p=0.190 n=5+4) pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64 _directGzip-2 1.44 ± 7% 1.53 ± 4% ~ (p=0.056 n=5+5) _directGzipHead-2 1.42 ± 6% 1.47 ± 5% ~ (p=0.333 n=5+5) _noDirectGzip-2 7.46 ± 3% 7.67 ± 6% ~ (p=0.310 n=5+5) _directGzip_decode-2 23.8 ±11% 22.9 ± 9% ~ (p=0.548 n=5+5) _noDirectGzip_decode-2 7.55 ± 5% 7.61 ± 4% ~ (p=0.690 n=5+5) _htmlResponse-2 2.17 ± 5% 2.21 ± 3% ~ (p=0.548 n=5+5) _jsonBodyManual-2 1.62 ± 4% 1.67 ± 7% ~ (p=0.389 n=5+5) _jsonBody-2 2.29 ± 6% 2.21 ± 4% ~ (p=0.222 n=5+5) _jsonBodyValidation-2 2.79 ± 4% 2.94 ± 3% +5.65% (p=0.032 n=5+5) _outputHeaders-2 1.42 ± 6% 1.39 ± 6% ~ (p=0.548 n=5+5) _requestResponseMapping-2 2.41 ± 8% 2.32 ± 3% ~ (p=0.151 n=5+5) _validation-2 2.62 ± 7% 2.69 ± 7% ~ (p=0.278 n=5+5) _noValidation-2 2.00 ± 6% 2.00 ± 3% ~ (p=0.690 n=5+5) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 1.64 ± 8% 1.56 ± 4% ~ (p=0.286 n=5+5) _ok-2 1.62 ± 2% 1.64 ±11% ~ (p=1.000 n=5+5) _invalidBody-2 2.15 ± 5% 2.11 ± 4% ~ (p=0.690 n=5+5) name old 90%:ms new 90%:ms delta pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64 _directGzip-2 2.59 ± 5% 2.52 ± 4% ~ (p=0.222 n=5+5) _directGzipHead-2 2.52 ± 4% 2.58 ± 3% ~ (p=0.151 n=5+5) _noDirectGzip-2 13.4 ± 6% 13.6 ± 4% ~ (p=0.516 n=5+5) _directGzip_decode-2 49.4 ± 8% 50.9 ± 5% ~ (p=0.310 n=5+5) _noDirectGzip_decode-2 13.3 ± 6% 13.6 ± 6% ~ (p=0.690 n=5+5) _jsonBody-2 5.11 ± 5% 5.18 ± 4% ~ (p=0.841 n=5+5) _jsonBodyValidation-2 6.12 ± 8% 5.90 ± 8% ~ (p=0.310 n=5+5) _outputHeaders-2 2.42 ± 6% 2.47 ± 6% ~ (p=0.548 n=5+5) _requestResponseMapping-2 5.30 ± 7% 5.39 ± 8% ~ (p=0.690 n=5+5) _validation-2 5.34 ± 4% 5.39 ± 6% ~ (p=0.841 n=5+5) _noValidation-2 3.82 ± 6% 3.95 ± 5% ~ (p=0.222 n=5+5) pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64 _directGzip-2 2.57 ±11% 2.73 ± 5% ~ (p=0.151 n=5+5) _directGzipHead-2 2.53 ± 7% 2.68 ± 6% ~ (p=0.111 n=5+5) _noDirectGzip-2 13.3 ± 3% 13.2 ± 4% ~ (p=0.690 n=5+5) _directGzip_decode-2 50.6 ± 4% 49.2 ±11% ~ (p=0.222 n=5+5) _noDirectGzip_decode-2 13.7 ± 5% 13.2 ± 4% ~ (p=0.548 n=5+5) _htmlResponse-2 4.31 ±13% 4.43 ± 6% ~ (p=0.310 n=5+5) _jsonBodyManual-2 2.93 ± 9% 3.05 ± 4% ~ (p=0.310 n=5+5) _jsonBody-2 4.67 ± 8% 4.71 ± 4% ~ (p=0.690 n=5+5) _jsonBodyValidation-2 6.05 ± 9% 5.99 ± 5% ~ (p=0.841 n=5+5) _outputHeaders-2 2.48 ± 6% 2.51 ± 5% ~ (p=0.952 n=5+5) _requestResponseMapping-2 5.56 ± 7% 5.44 ± 7% ~ (p=0.421 n=5+5) _validation-2 5.78 ± 9% 5.81 ± 6% ~ (p=1.000 n=5+5) _noValidation-2 3.90 ±10% 3.88 ± 7% ~ (p=0.841 n=5+5) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 2.95 ±17% 2.93 ± 6% ~ (p=0.460 n=5+5) _ok-2 2.92 ± 5% 2.98 ±11% ~ (p=0.841 n=5+5) _invalidBody-2 4.40 ± 7% 4.38 ± 7% ~ (p=0.841 n=5+5) name old 99%:ms new 99%:ms delta pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64 _directGzip-2 6.43 ±22% 4.56 ±10% -29.08% (p=0.016 n=5+4) _directGzipHead-2 4.73 ± 8% 4.90 ±14% ~ (p=0.841 n=5+5) _noDirectGzip-2 20.8 ±13% 20.9 ± 7% ~ (p=0.841 n=5+5) _directGzip_decode-2 87.2 ±13% 83.2 ± 5% ~ (p=0.421 n=5+5) _noDirectGzip_decode-2 20.3 ± 7% 19.9 ± 5% ~ (p=0.690 n=5+5) _jsonBody-2 8.35 ±11% 8.21 ±13% ~ (p=1.000 n=5+5) _jsonBodyValidation-2 10.3 ±17% 9.9 ±20% ~ (p=0.841 n=5+5) _outputHeaders-2 5.34 ±10% 5.17 ±17% ~ (p=0.841 n=5+5) _requestResponseMapping-2 8.35 ±10% 8.79 ±11% ~ (p=0.222 n=5+5) _validation-2 8.59 ± 8% 8.66 ±10% ~ (p=0.841 n=5+5) _noValidation-2 7.08 ±14% 7.57 ±12% ~ (p=0.222 n=5+5) pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64 _directGzip-2 4.46 ± 9% 4.84 ±12% ~ (p=0.190 n=4+5) _directGzipHead-2 4.74 ±11% 6.04 ±72% ~ (p=0.222 n=5+5) _noDirectGzip-2 19.5 ± 4% 20.1 ± 4% ~ (p=0.222 n=5+5) _directGzip_decode-2 88.8 ±23% 81.9 ± 8% ~ (p=0.524 n=5+5) _noDirectGzip_decode-2 21.2 ± 9% 20.5 ± 5% ~ (p=0.690 n=5+5) _htmlResponse-2 7.53 ± 6% 7.80 ±22% ~ (p=0.841 n=5+5) _jsonBodyManual-2 5.71 ± 7% 5.62 ± 6% ~ (p=0.548 n=5+5) _jsonBody-2 8.16 ±20% 8.12 ±13% ~ (p=1.000 n=5+5) _jsonBodyValidation-2 9.36 ±18% 9.09 ±21% ~ (p=0.690 n=5+5) _outputHeaders-2 5.32 ± 8% 5.57 ±14% ~ (p=0.690 n=5+5) _requestResponseMapping-2 9.83 ±14% 8.61 ±15% ~ (p=0.095 n=5+5) _validation-2 9.93 ±13% 9.56 ±12% ~ (p=0.690 n=5+5) _noValidation-2 7.71 ±10% 8.06 ±15% ~ (p=0.548 n=5+5) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 4.76 ± 6% 4.60 ± 5% ~ (p=0.486 n=4+4) _ok-2 4.66 ± 2% 5.28 ±28% ~ (p=0.111 n=4+5) _invalidBody-2 8.23 ±10% 8.46 ±19% ~ (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-2 11.5 ±17% 9.0 ±70% ~ (p=0.310 n=5+5) _directGzipHead-2 8.57 ±34% 8.70 ±46% ~ (p=1.000 n=5+5) _noDirectGzip-2 25.2 ±36% 26.1 ±11% ~ (p=0.310 n=5+5) _directGzip_decode-2 118 ±34% 105 ±10% ~ (p=0.690 n=5+5) _noDirectGzip_decode-2 25.4 ±39% 23.0 ± 8% ~ (p=0.841 n=5+5) _jsonBody-2 15.1 ±21% 13.1 ± 9% ~ (p=0.222 n=5+5) _jsonBodyValidation-2 15.3 ±14% 16.3 ±30% ~ (p=1.000 n=5+5) _outputHeaders-2 10.3 ± 7% 9.4 ±44% ~ (p=0.690 n=5+5) _requestResponseMapping-2 14.6 ±29% 14.2 ±13% ~ (p=0.690 n=5+5) _validation-2 14.3 ±40% 15.2 ±29% ~ (p=0.841 n=5+5) _noValidation-2 12.0 ±37% 13.8 ±59% ~ (p=0.548 n=5+5) pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64 _directGzip-2 10.9 ±117% 9.4 ±36% ~ (p=0.690 n=5+5) _directGzipHead-2 8.16 ±38% 11.56 ±33% ~ (p=0.151 n=5+5) _noDirectGzip-2 22.5 ± 6% 23.5 ± 2% ~ (p=0.151 n=5+5) _directGzip_decode-2 116 ±19% 111 ±11% ~ (p=1.000 n=5+5) _noDirectGzip_decode-2 28.1 ±22% 23.0 ± 5% ~ (p=0.222 n=5+5) _htmlResponse-2 12.2 ±18% 12.7 ±34% ~ (p=0.841 n=5+5) _jsonBodyManual-2 11.2 ±30% 10.1 ±20% ~ (p=0.690 n=5+5) _jsonBody-2 14.3 ±38% 13.6 ±32% ~ (p=0.841 n=5+5) _jsonBodyValidation-2 15.2 ±47% 13.0 ±30% ~ (p=0.421 n=5+5) _outputHeaders-2 11.2 ±36% 10.9 ±59% ~ (p=0.690 n=5+5) _requestResponseMapping-2 15.1 ±24% 14.8 ±35% ~ (p=0.841 n=5+5) _validation-2 16.9 ±18% 15.2 ±24% ~ (p=0.310 n=5+5) _noValidation-2 12.8 ±28% 12.0 ±19% ~ (p=1.000 n=5+5) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 10.1 ±96% 8.1 ±87% ~ (p=0.421 n=5+5) _ok-2 7.63 ±14% 10.94 ±48% ~ (p=0.151 n=5+5) _invalidBody-2 12.7 ±48% 11.5 ±44% ~ (p=0.690 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-2 639 ± 0% 639 ± 0% ~ (all equal) _directGzipHead-2 183 ± 0% 183 ± 0% ~ (all equal) _noDirectGzip-2 1.04k ± 0% 1.04k ± 0% ~ (all equal) _directGzip_decode-2 639 ± 0% 639 ± 0% ~ (all equal) _noDirectGzip_decode-2 1.04k ± 0% 1.04k ± 0% ~ (all equal) _jsonBody-2 208 ± 0% 208 ± 0% ~ (all equal) _jsonBodyValidation-2 194 ± 0% 194 ± 0% ~ (all equal) _outputHeaders-2 155 ± 0% 155 ± 0% ~ (all equal) _requestResponseMapping-2 94.0 ± 0% 94.0 ± 0% ~ (all equal) _validation-2 177 ± 0% 177 ± 0% ~ (all equal) _noValidation-2 177 ± 0% 177 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64 _directGzip-2 653 ± 0% 653 ± 0% ~ (all equal) _directGzipHead-2 197 ± 0% 197 ± 0% ~ (all equal) _noDirectGzip-2 1.06k ± 0% 1.06k ± 0% ~ (all equal) _directGzip_decode-2 653 ± 0% 653 ± 0% ~ (all equal) _noDirectGzip_decode-2 1.06k ± 0% 1.06k ± 0% ~ (all equal) _htmlResponse-2 370 ± 0% 370 ± 0% ~ (all equal) _jsonBodyManual-2 222 ± 0% 222 ± 0% ~ (all equal) _jsonBody-2 222 ± 0% 222 ± 0% ~ (all equal) _jsonBodyValidation-2 208 ± 0% 208 ± 0% ~ (all equal) _outputHeaders-2 169 ± 0% 169 ± 0% ~ (all equal) _requestResponseMapping-2 108 ± 0% 108 ± 0% ~ (all equal) _validation-2 191 ± 0% 191 ± 0% ~ (all equal) _noValidation-2 191 ± 0% 191 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 337 ± 0% 337 ± 0% ~ (all equal) _ok-2 359 ± 0% 359 ± 0% ~ (all equal) _invalidBody-2 435 ± 0% 435 ± 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-2 103 ± 0% 103 ± 0% ~ (all equal) _directGzipHead-2 104 ± 0% 104 ± 0% ~ (all equal) _noDirectGzip-2 117 ± 0% 117 ± 0% ~ (all equal) _directGzip_decode-2 116 ± 0% 116 ± 0% ~ (all equal) _noDirectGzip_decode-2 130 ± 0% 130 ± 0% ~ (all equal) _jsonBody-2 188 ± 0% 188 ± 0% ~ (all equal) _jsonBodyValidation-2 192 ± 0% 192 ± 0% ~ (all equal) _outputHeaders-2 77.0 ± 0% 77.0 ± 0% ~ (all equal) _requestResponseMapping-2 169 ± 0% 169 ± 0% ~ (all equal) _validation-2 170 ± 0% 170 ± 0% ~ (all equal) _noValidation-2 173 ± 0% 173 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64 _directGzip-2 103 ± 0% 103 ± 0% ~ (all equal) _directGzipHead-2 104 ± 0% 104 ± 0% ~ (all equal) _noDirectGzip-2 117 ± 0% 117 ± 0% ~ (all equal) _directGzip_decode-2 116 ± 0% 116 ± 0% ~ (all equal) _noDirectGzip_decode-2 130 ± 0% 130 ± 0% ~ (all equal) _htmlResponse-2 108 ± 0% 108 ± 0% ~ (all equal) _jsonBodyManual-2 195 ± 0% 195 ± 0% ~ (all equal) _jsonBody-2 188 ± 0% 188 ± 0% ~ (all equal) _jsonBodyValidation-2 192 ± 0% 192 ± 0% ~ (all equal) _outputHeaders-2 77.0 ± 0% 77.0 ± 0% ~ (all equal) _requestResponseMapping-2 169 ± 0% 169 ± 0% ~ (all equal) _validation-2 170 ± 0% 170 ± 0% ~ (all equal) _noValidation-2 173 ± 0% 173 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 74.0 ± 0% 74.0 ± 0% ~ (all equal) _ok-2 74.0 ± 0% 74.0 ± 0% ~ (all equal) _invalidBody-2 137 ± 0% 137 ± 0% ~ (all equal) name old rps new rps delta pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64 _directGzip-2 31.7k ± 5% 32.7k ±13% ~ (p=0.222 n=5+5) _directGzipHead-2 33.4k ± 2% 33.1k ± 1% ~ (p=0.548 n=5+5) _noDirectGzip-2 6.35k ± 4% 6.31k ± 4% ~ (p=0.548 n=5+5) _directGzip_decode-2 1.70k ± 5% 1.65k ± 4% ~ (p=0.222 n=5+5) _noDirectGzip_decode-2 6.45k ± 1% 6.38k ± 4% ~ (p=0.421 n=5+5) _jsonBody-2 17.9k ± 5% 17.9k ± 4% ~ (p=1.000 n=5+5) _jsonBodyValidation-2 15.4k ± 6% 15.2k ± 7% ~ (p=0.841 n=5+5) _outputHeaders-2 34.1k ± 4% 34.1k ± 7% ~ (p=1.000 n=5+5) _requestResponseMapping-2 18.5k ± 4% 17.9k ± 4% ~ (p=0.222 n=5+5) _validation-2 17.4k ± 4% 17.1k ± 5% ~ (p=0.095 n=5+5) _noValidation-2 23.6k ± 4% 23.2k ± 4% ~ (p=0.548 n=5+5) pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64 _directGzip-2 31.8k ±15% 31.8k ± 4% ~ (p=0.310 n=5+5) _directGzipHead-2 33.1k ± 2% 31.2k ±11% -5.83% (p=0.032 n=5+5) _noDirectGzip-2 6.40k ± 1% 6.35k ± 1% ~ (p=0.151 n=5+5) _directGzip_decode-2 1.64k ± 6% 1.70k ± 4% ~ (p=0.222 n=5+5) _noDirectGzip_decode-2 6.30k ± 3% 6.40k ± 1% ~ (p=0.690 n=5+5) _htmlResponse-2 20.6k ± 5% 20.4k ± 5% ~ (p=0.841 n=5+5) _jsonBodyManual-2 28.4k ± 2% 27.9k ± 3% ~ (p=0.222 n=5+5) _jsonBody-2 19.8k ± 3% 19.8k ± 4% ~ (p=1.000 n=5+5) _jsonBodyValidation-2 15.2k ± 7% 15.4k ± 6% ~ (p=0.690 n=5+5) _outputHeaders-2 33.1k ± 6% 33.3k ± 3% ~ (p=0.841 n=5+5) _requestResponseMapping-2 17.3k ± 8% 17.7k ± 4% ~ (p=0.548 n=5+5) _validation-2 16.0k ± 6% 16.4k ± 5% ~ (p=0.421 n=5+5) _noValidation-2 23.0k ± 2% 22.5k ± 4% ~ (p=0.548 n=5+5) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 28.5k ±14% 29.4k ± 9% ~ (p=0.421 n=5+5) _ok-2 29.5k ± 6% 28.9k ± 8% ~ (p=0.421 n=5+5) _invalidBody-2 20.8k ± 2% 20.8k ± 2% ~ (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-2 3.93kB ± 0% 3.93kB ± 0% ~ (p=0.127 n=5+5) _directGzipHead-2 3.93kB ± 0% 3.93kB ± 0% ~ (p=0.524 n=5+5) _noDirectGzip-2 7.28kB ±15% 7.24kB ±13% ~ (p=1.000 n=5+5) _directGzip_decode-2 403kB ± 0% 403kB ± 0% ~ (p=0.841 n=5+5) _noDirectGzip_decode-2 5.84kB ± 4% 5.83kB ± 7% ~ (p=0.841 n=5+5) _jsonBody-2 13.3kB ± 0% 13.3kB ± 0% ~ (p=1.000 n=5+5) _jsonBodyValidation-2 19.0kB ± 0% 19.0kB ± 0% ~ (p=0.294 n=5+5) _outputHeaders-2 3.72kB ± 0% 3.72kB ± 0% ~ (p=0.802 n=5+5) _requestResponseMapping-2 16.7kB ± 0% 16.7kB ± 0% ~ (p=0.833 n=5+5) _validation-2 16.6kB ± 0% 16.6kB ± 0% ~ (p=0.952 n=5+5) _noValidation-2 7.90kB ± 0% 7.90kB ± 0% ~ (p=0.817 n=5+5) pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64 _directGzip-2 3.98kB ± 0% 3.98kB ± 0% ~ (p=0.206 n=5+5) _directGzipHead-2 3.98kB ± 0% 3.98kB ± 0% ~ (p=0.079 n=5+5) _noDirectGzip-2 7.17kB ±16% 7.50kB ±19% ~ (p=0.548 n=5+5) _directGzip_decode-2 403kB ± 0% 403kB ± 0% ~ (p=0.095 n=5+5) _noDirectGzip_decode-2 6.02kB ± 7% 5.96kB ± 8% ~ (p=0.841 n=5+5) _htmlResponse-2 8.26kB ± 0% 8.26kB ± 0% ~ (p=0.794 n=5+5) _jsonBodyManual-2 4.66kB ± 0% 4.66kB ± 0% ~ (p=0.897 n=5+5) _jsonBody-2 10.4kB ± 0% 10.4kB ± 0% ~ (p=0.190 n=5+5) _jsonBodyValidation-2 19.1kB ± 0% 19.1kB ± 0% ~ (p=0.786 n=5+5) _outputHeaders-2 3.75kB ± 0% 3.75kB ± 0% ~ (p=0.413 n=5+5) _requestResponseMapping-2 16.8kB ± 0% 16.8kB ± 0% ~ (p=0.643 n=5+5) _validation-2 16.7kB ± 0% 16.7kB ± 0% ~ (p=0.143 n=5+5) _noValidation-2 7.96kB ± 0% 7.96kB ± 0% ~ (p=1.000 n=5+5) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 4.89kB ± 0% 4.89kB ± 0% ~ (p=0.524 n=5+5) _ok-2 4.79kB ± 0% 4.79kB ± 0% ~ (p=1.000 n=4+4) _invalidBody-2 8.63kB ± 0% 8.64kB ± 0% ~ (p=0.257 n=4+4) name old allocs/op new allocs/op delta pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64 _directGzip-2 42.0 ± 0% 42.0 ± 0% ~ (all equal) _directGzipHead-2 42.0 ± 0% 42.0 ± 0% ~ (all equal) _noDirectGzip-2 49.8 ± 4% 49.8 ± 4% ~ (p=1.000 n=5+5) _directGzip_decode-2 503 ± 0% 503 ± 0% ~ (p=1.000 n=5+5) _noDirectGzip_decode-2 50.0 ± 0% 50.0 ± 0% ~ (all equal) _jsonBody-2 130 ± 0% 130 ± 0% ~ (all equal) _jsonBodyValidation-2 186 ± 0% 186 ± 0% ~ (all equal) _outputHeaders-2 37.0 ± 0% 37.0 ± 0% ~ (all equal) _requestResponseMapping-2 126 ± 0% 126 ± 0% ~ (all equal) _validation-2 155 ± 0% 155 ± 0% ~ (all equal) _noValidation-2 92.0 ± 0% 92.0 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64 _directGzip-2 44.0 ± 0% 44.0 ± 0% ~ (all equal) _directGzipHead-2 44.0 ± 0% 44.0 ± 0% ~ (all equal) _noDirectGzip-2 51.8 ± 3% 51.8 ± 3% ~ (p=1.000 n=5+5) _directGzip_decode-2 505 ± 0% 504 ± 0% -0.20% (p=0.016 n=4+5) _noDirectGzip_decode-2 52.0 ± 0% 52.0 ± 0% ~ (all equal) _htmlResponse-2 145 ± 0% 145 ± 0% ~ (all equal) _jsonBodyManual-2 51.0 ± 0% 51.0 ± 0% ~ (all equal) _jsonBody-2 102 ± 0% 102 ± 0% ~ (all equal) _jsonBodyValidation-2 188 ± 0% 188 ± 0% ~ (all equal) _outputHeaders-2 38.0 ± 0% 38.0 ± 0% ~ (all equal) _requestResponseMapping-2 128 ± 0% 128 ± 0% ~ (all equal) _validation-2 157 ± 0% 157 ± 0% ~ (all equal) _noValidation-2 94.0 ± 0% 94.0 ± 0% ~ (all equal) pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64 _notFoundSrv-2 54.0 ± 0% 54.0 ± 0% ~ (all equal) _ok-2 50.0 ± 0% 50.0 ± 0% ~ (all equal) _invalidBody-2 99.0 ± 0% 99.0 ± 0% ~ (all equal) ```
github-actions[bot] commented 1 year ago

Unit Test Coverage

total: (statements) 83.9% changed lines: (statements) 91.7%

Coverage of changed lines | File | Function | Coverage | |------------------------|---------------------|----------| | Total | | 91.7% | | response/encoder.go | | 91.7% | | response/encoder.go:46 | setupHeadersEncoder | 100.0% | | response/encoder.go:81 | SetupOutput | 95.1% |
Coverage diff with base branch | File | Function | Base Coverage | Current Coverage | |----------------------------------------------|---------------------|---------------|------------------| | Total | | 83.9% | 83.9% (0.0%) | | github.com/swaggest/rest/response/encoder.go | SetupOutput | 82.4% | 89.5% (+7.1%) | | github.com/swaggest/rest/response/encoder.go | setupHeadersEncoder | no function | 77.8% |
codecov[bot] commented 1 year ago

Codecov Report

Merging #105 (ecf279c) into master (940c1e7) will increase coverage by 0.02%. The diff coverage is 80.00%.

@@            Coverage Diff             @@
##           master     #105      +/-   ##
==========================================
+ Coverage   78.02%   78.05%   +0.02%     
==========================================
  Files          28       28              
  Lines        1470     1472       +2     
==========================================
+ Hits         1147     1149       +2     
  Misses        208      208              
  Partials      115      115              
Flag Coverage Δ
unittests 78.05% <80.00%> (+0.02%) :arrow_up:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
response/encoder.go 65.29% <80.00%> (+0.41%) :arrow_up:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more