Repository: swaggest/rest
Pull request #59 (2022-02-08 23:13:43)

Allow non-pointer output values

github-actions[bot]: ### Lines Of Code

| Language  | Files |   Lines    |    Code    | Comments |  Blanks   | Complexity |     Bytes      |
|-----------|-------|------------|------------|----------|-----------|------------|----------------|
| Go        | 96    | 6306 (+14) | 4563 (+9)  | 435 (+1) | 1308 (+4) | 707 (+2)   | 154.1K (+323B) |
| Go (test) | 43    | 4187 (+44) | 3210 (+33) | 127      | 850 (+11) | 113        | 116.9K (+1.1K) |
<!-- Sticky Pull Request CommentLOC -->
github-actions[bot]: ### Unit Test Coverage
total:	(statements)	83.1%
<details><summary>Coverage diff with base branch</summary>

```diff
116c116,117
< github.com/swaggest/rest/response/encoder.go	SetupOutput	81.8%
---
> github.com/swaggest/rest/response/encoder.go	addressable	100.0%
> github.com/swaggest/rest/response/encoder.go	SetupOutput	82.4%
159c160
< total:	(statements)	83.0%
---
> total:	(statements)	83.1%
```
</details>
<!-- Sticky Pull Request Commentunit-test -->
github-actions[bot]: ### Go API Changes

<pre>
# summary
Inferred base version: v0.2.20
Suggested version: v0.2.21
</pre>
<!-- Sticky Pull Request Commentgorelease -->
codecov[bot]: # [Codecov](https://codecov.io/gh/swaggest/rest/pull/59?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest) Report
> Merging [#59](https://codecov.io/gh/swaggest/rest/pull/59?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest) (c7e24d7) into [master](https://codecov.io/gh/swaggest/rest/commit/8066f6e9100bb0b698bdc576cd357b5c0604cc65?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest) (8066f6e) will **increase** coverage by `0.10%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/swaggest/rest/pull/59/graphs/tree.svg?width=650&height=150&src=pr&token=OpLHxxPdmn&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest)](https://codecov.io/gh/swaggest/rest/pull/59?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest)

```diff
@@            Coverage Diff             @@
##           master      #59      +/-   ##
==========================================
+ Coverage   76.68%   76.79%   +0.10%     
==========================================
  Files          27       27              
  Lines        1304     1310       +6     
==========================================
+ Hits         1000     1006       +6     
  Misses        189      189              
  Partials      115      115              
```

| Flag | Coverage Δ | |
|---|---|---|
| unittests | `76.79% <100.00%> (+0.10%)` | :arrow_up: |

Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest#carryforward-flags-in-the-pull-request-comment) to find out more.

| [Impacted Files](https://codecov.io/gh/swaggest/rest/pull/59?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest) | Coverage Δ | |
|---|---|---|
| [response/encoder.go](https://codecov.io/gh/swaggest/rest/pull/59/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest#diff-cmVzcG9uc2UvZW5jb2Rlci5nbw==) | `64.88% <100.00%> (+1.30%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/swaggest/rest/pull/59?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/swaggest/rest/pull/59?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest). Last update [8066f6e...c7e24d7](https://codecov.io/gh/swaggest/rest/pull/59?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=swaggest).

github-actions[bot]: ### Benchmark Result
<details><summary>Benchmark diff with base branch</summary>

```
name                                    old time/op    new time/op    delta
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-2    1.48µs ± 1%    1.50µs ± 4%     ~     (p=0.548 n=5+5)
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                           773ns ± 5%     807ns ± 7%     ~     (p=0.151 n=5+5)
DecoderFunc_Decode-2                      2.20µs ± 5%    2.43µs ± 5%  +10.61%  (p=0.008 n=5+5)
Decoder_Decode_json-2                     24.5µs ± 2%    25.3µs ± 3%     ~     (p=0.056 n=5+5)
Decoder_Decode_queryObject-2              5.33µs ± 5%    5.45µs ± 2%     ~     (p=0.151 n=5+5)
Decoder_Decode_jsonParam-2                2.13µs ± 4%    2.09µs ± 3%     ~     (p=0.222 n=5+5)
DecoderFactory_SetDecoderFunc-2           1.84µs ± 3%    1.91µs ± 6%     ~     (p=0.095 n=5+5)
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-2                              12.6µs ± 4%    12.5µs ± 1%     ~     (p=0.690 n=5+5)
Middleware_control-2                      3.80µs ± 4%    3.77µs ± 2%     ~     (p=0.841 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.15kB ± 1%    1.14kB ± 2%     ~     (p=0.246 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)
```
</details>

<details><summary>Benchmark result</summary>

```
name                                    time/op
pkg:github.com/swaggest/rest/jsonschema goos:linux goarch:amd64
RequestValidator_ValidateRequestData-2  1.50µs ± 4%
pkg:github.com/swaggest/rest/request goos:linux goarch:amd64
Decoder_Decode-2                         807ns ± 7%
DecoderFunc_Decode-2                    2.43µs ± 5%
Decoder_Decode_json-2                   25.3µs ± 3%
Decoder_Decode_queryObject-2            5.45µs ± 2%
Decoder_Decode_jsonParam-2              2.09µs ± 3%
DecoderFactory_SetDecoderFunc-2         1.91µs ± 6%
pkg:github.com/swaggest/rest/response/gzip goos:linux goarch:amd64
Middleware-2                            12.5µs ± 1%
Middleware_control-2                    3.77µs ± 2%

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.14kB ± 2%
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%
```
</details>
<!-- Sticky Pull Request Commentbench -->
github-actions[bot]: ### Examples Benchmark Result
<details><summary>Benchmark diff with base branch</summary>

```
name                       old time/op    new time/op    delta
pkg:github.com/swaggest/rest/_examples/advanced goos:linux goarch:amd64
_directGzip-2                38.0µs ±13%    39.0µs ± 1%     ~     (p=0.548 n=5+5)
_directGzipHead-2            37.3µs ± 7%    37.7µs ± 3%     ~     (p=0.841 n=5+5)
_noDirectGzip-2               170µs ± 3%     173µs ± 2%     ~     (p=0.548 n=5+5)
_directGzip_decode-2          522µs ± 6%     557µs ± 4%   +6.79%  (p=0.016 n=5+5)
_noDirectGzip_decode-2        167µs ± 1%     177µs ± 2%   +6.43%  (p=0.008 n=5+5)
_jsonBody-2                  63.1µs ± 5%    64.2µs ± 2%     ~     (p=0.222 n=5+5)
_jsonBodyValidation-2        68.6µs ± 3%    75.9µs ± 4%  +10.60%  (p=0.008 n=5+5)
_outputHeaders-2             36.8µs ± 3%    36.4µs ± 1%     ~     (p=0.548 n=5+5)
_requestResponseMapping-2    59.1µs ± 2%    60.4µs ± 6%     ~     (p=0.421 n=5+5)
_validation-2                64.3µs ± 4%    66.4µs ± 4%     ~     (p=0.151 n=5+5)
_noValidation-2              45.8µs ± 3%    46.9µs ± 4%     ~     (p=0.730 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                39.9µs ±16%    41.2µs ±16%     ~     (p=0.310 n=5+5)
_directGzipHead-2            37.5µs ± 2%    38.6µs ± 3%   +3.14%  (p=0.032 n=5+5)
_noDirectGzip-2               171µs ± 5%     179µs ± 2%   +4.95%  (p=0.016 n=5+5)
_directGzip_decode-2          515µs ± 5%     571µs ± 4%  +10.95%  (p=0.008 n=5+5)
_noDirectGzip_decode-2        168µs ± 2%     179µs ± 3%   +6.50%  (p=0.008 n=5+5)
_jsonBody-2                  64.5µs ± 2%    67.7µs ± 1%   +5.00%  (p=0.008 n=5+5)
_jsonBodyValidation-2        70.1µs ± 3%    72.3µs ± 4%     ~     (p=0.095 n=5+5)
_outputHeaders-2             37.2µs ± 4%    37.4µs ± 3%     ~     (p=0.690 n=5+5)
_requestResponseMapping-2    63.5µs ± 7%    66.2µs ± 4%     ~     (p=0.222 n=5+5)
_validation-2                66.4µs ± 8%    71.6µs ± 6%     ~     (p=0.056 n=5+5)
_noValidation-2              69.0µs ± 5%    70.7µs ± 1%     ~     (p=0.095 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2               45.3µs ± 9%    47.4µs ±13%     ~     (p=0.421 n=5+5)
_ok-2                        47.1µs ± 6%    47.5µs ± 2%     ~     (p=0.310 n=5+5)
_invalidBody-2               63.0µs ± 6%    64.5µs ± 4%     ~     (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-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                   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/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)
_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                 26.4k ±12%     25.7k ± 1%     ~     (p=0.548 n=5+5)
_directGzipHead-2             26.9k ± 7%     26.5k ± 3%     ~     (p=0.841 n=5+5)
_noDirectGzip-2               5.87k ± 3%     5.79k ± 2%     ~     (p=0.548 n=5+5)
_directGzip_decode-2          1.92k ± 6%     1.80k ± 4%   -6.39%  (p=0.016 n=5+5)
_noDirectGzip_decode-2        6.00k ± 1%     5.64k ± 2%   -6.02%  (p=0.008 n=5+5)
_jsonBody-2                   15.8k ± 5%     15.6k ± 2%     ~     (p=0.222 n=5+5)
_jsonBodyValidation-2         14.6k ± 3%     13.2k ± 4%   -9.57%  (p=0.008 n=5+5)
_outputHeaders-2              27.2k ± 3%     27.5k ± 1%     ~     (p=0.548 n=5+5)
_requestResponseMapping-2     16.9k ± 2%     16.6k ± 6%     ~     (p=0.421 n=5+5)
_validation-2                 15.6k ± 4%     15.1k ± 4%     ~     (p=0.151 n=5+5)
_noValidation-2               21.8k ± 3%     21.4k ± 4%     ~     (p=0.730 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                 25.2k ±14%     24.4k ±15%     ~     (p=0.310 n=5+5)
_directGzipHead-2             26.7k ± 2%     25.9k ± 3%   -3.01%  (p=0.032 n=5+5)
_noDirectGzip-2               5.86k ± 5%     5.58k ± 2%   -4.77%  (p=0.016 n=5+5)
_directGzip_decode-2          1.94k ± 5%     1.75k ± 4%   -9.89%  (p=0.008 n=5+5)
_noDirectGzip_decode-2        5.96k ± 2%     5.60k ± 3%   -6.10%  (p=0.008 n=5+5)
_jsonBody-2                   15.5k ± 2%     14.8k ± 1%   -4.77%  (p=0.008 n=5+5)
_jsonBodyValidation-2         14.3k ± 3%     13.8k ± 4%     ~     (p=0.095 n=5+5)
_outputHeaders-2              26.9k ± 4%     26.7k ± 3%     ~     (p=0.690 n=5+5)
_requestResponseMapping-2     15.8k ± 7%     15.1k ± 4%     ~     (p=0.222 n=5+5)
_validation-2                 15.1k ± 8%     14.0k ± 6%     ~     (p=0.056 n=5+5)
_noValidation-2               14.5k ± 5%     14.1k ± 1%     ~     (p=0.095 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2                22.1k ± 9%     21.2k ±12%     ~     (p=0.421 n=5+5)
_ok-2                         21.2k ± 6%     21.0k ± 2%     ~     (p=0.310 n=5+5)
_invalidBody-2                15.9k ± 6%     15.5k ± 4%     ~     (p=0.548 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%   +0.06%  (p=0.024 n=5+5)
_directGzipHead-2            3.93kB ± 0%    3.93kB ± 0%     ~     (p=0.619 n=5+5)
_noDirectGzip-2              6.60kB ±20%    6.72kB ±21%     ~     (p=1.000 n=5+5)
_directGzip_decode-2          402kB ± 0%     402kB ± 0%     ~     (p=0.841 n=5+5)
_noDirectGzip_decode-2       5.42kB ± 9%    5.38kB ±11%     ~     (p=1.000 n=5+5)
_jsonBody-2                  13.2kB ± 0%    13.2kB ± 0%     ~     (p=0.849 n=5+5)
_jsonBodyValidation-2        19.0kB ± 0%    19.0kB ± 0%     ~     (p=0.238 n=5+5)
_outputHeaders-2             3.71kB ± 0%    3.72kB ± 0%     ~     (p=0.397 n=5+4)
_requestResponseMapping-2    16.7kB ± 0%    16.7kB ± 0%     ~     (p=0.190 n=5+5)
_validation-2                16.6kB ± 0%    16.6kB ± 0%     ~     (p=0.159 n=5+4)
_noValidation-2              6.13kB ± 0%    6.13kB ± 0%     ~     (p=0.730 n=5+5)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                3.95kB ± 0%    3.95kB ± 0%     ~     (p=0.087 n=5+5)
_directGzipHead-2            3.94kB ± 0%    3.95kB ± 0%     ~     (p=0.397 n=5+5)
_noDirectGzip-2              7.14kB ±24%    6.58kB ±15%     ~     (p=0.310 n=5+5)
_directGzip_decode-2          402kB ± 0%     402kB ± 0%     ~     (p=0.841 n=5+5)
_noDirectGzip_decode-2       5.37kB ± 4%    5.62kB ±11%     ~     (p=0.548 n=5+5)
_jsonBody-2                  13.3kB ± 0%    13.3kB ± 0%     ~     (p=0.056 n=5+5)
_jsonBodyValidation-2        19.0kB ± 0%    19.0kB ± 0%     ~     (p=0.786 n=5+5)
_outputHeaders-2             3.72kB ± 0%    3.72kB ± 0%     ~     (p=0.492 n=5+5)
_requestResponseMapping-2    16.7kB ± 0%    16.7kB ± 0%     ~     (p=0.286 n=5+5)
_validation-2                16.6kB ± 0%    16.6kB ± 0%     ~     (p=0.159 n=5+4)
_noValidation-2              16.6kB ± 0%    16.6kB ± 0%     ~     (p=0.389 n=5+5)
pkg:github.com/swaggest/rest/_examples/task-api/internal/infra/nethttp goos:linux goarch:amd64
_notFoundSrv-2               4.88kB ± 0%    4.88kB ± 0%     ~     (p=0.786 n=5+5)
_ok-2                        4.79kB ± 0%    4.79kB ± 0%     ~     (p=0.143 n=4+4)
_invalidBody-2               8.79kB ± 3%    8.79kB ± 3%     ~     (p=0.683 n=5+5)

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%      51.0 ± 0%     ~     (p=0.556 n=5+4)
_directGzip_decode-2            501 ± 0%       500 ± 0%     ~     (p=0.095 n=4+5)
_noDirectGzip_decode-2         50.0 ± 0%      50.0 ± 0%     ~     (all equal)
_jsonBody-2                     127 ± 0%       127 ± 0%     ~     (all equal)
_jsonBodyValidation-2           183 ± 0%       183 ± 0%     ~     (all equal)
_outputHeaders-2               37.0 ± 0%      37.0 ± 0%     ~     (all equal)
_requestResponseMapping-2       123 ± 0%       123 ± 0%     ~     (all equal)
_validation-2                   152 ± 0%       152 ± 0%     ~     (all equal)
_noValidation-2                72.0 ± 0%      72.0 ± 0%     ~     (all equal)
pkg:github.com/swaggest/rest/_examples/advanced-generic goos:linux goarch:amd64
_directGzip-2                  43.0 ± 0%      43.0 ± 0%     ~     (all equal)
_directGzipHead-2              43.0 ± 0%      43.0 ± 0%     ~     (all equal)
_noDirectGzip-2                51.2 ± 4%      51.0 ± 4%     ~     (p=1.000 n=5+5)
_directGzip_decode-2            501 ± 0%       501 ± 0%     ~     (all equal)
_noDirectGzip_decode-2         51.0 ± 0%      51.0 ± 0%     ~     (all equal)
_jsonBody-2                     128 ± 0%       128 ± 0%     ~     (all equal)
_jsonBodyValidation-2           184 ± 0%       184 ± 0%     ~     (all equal)
_outputHeaders-2               37.0 ± 0%      37.0 ± 0%     ~     (all equal)
_requestResponseMapping-2       124 ± 0%       124 ± 0%     ~     (all equal)
_validation-2                   153 ± 0%       153 ± 0%     ~     (all equal)
_noValidation-2                 153 ± 0%       153 ± 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                  101 ± 2%       101 ± 2%     ~     (p=1.000 n=5+5)
```
</details>
<!-- Sticky Pull Request Commentbench-examples -->

Patch:
diff --git a/response/encoder.go b/response/encoder.go
index 032dc65..0b16e4f 100644
--- a/response/encoder.go
+++ b/response/encoder.go
@@ -31,6 +31,18 @@ type noContent interface {
 	NoContent() bool
 }
 
+// addressable makes a pointer from a non-pointer values.
+func addressable(output interface{}) interface{} {
+	if reflect.ValueOf(output).Kind() != reflect.Ptr {
+		o := reflect.New(reflect.TypeOf(output))
+		o.Elem().Set(reflect.ValueOf(output))
+
+		output = o.Interface()
+	}
+
+	return output
+}
+
 // SetupOutput configures encoder with and instance of use case output.
 func (h *Encoder) SetupOutput(output interface{}, ht *rest.HandlerTrait) {
 	h.outputBufferType = reflect.TypeOf(output)
@@ -41,6 +53,8 @@ func (h *Encoder) SetupOutput(output interface{}, ht *rest.HandlerTrait) {
 		return
 	}
 
+	output = addressable(output)
+
 	// Enable dynamic headers check in interface mode.
 	if h.unwrapInterface = reflect.ValueOf(output).Elem().Kind() == reflect.Interface; h.unwrapInterface {
 		enc := form.NewEncoder()


Test patch:
diff --git a/response/encoder_test.go b/response/encoder_test.go
index dfef550..704d356 100644
--- a/response/encoder_test.go
+++ b/response/encoder_test.go
@@ -141,3 +141,47 @@ func TestEncoder_SetupOutput_withWriterContentType(t *testing.T) {
 	assert.Equal(t, "application/x-vnd-foo", w.Header().Get("Content-Type"))
 	assert.Equal(t, "1,2,3", w.Body.String())
 }
+
+func TestEncoder_SetupOutput_nonPtr(t *testing.T) {
+	e := response.Encoder{}
+
+	type outputPort struct {
+		Name  string   `header:"X-Name" json:"-"`
+		Items []string `json:"items"`
+	}
+
+	ht := rest.HandlerTrait{
+		SuccessContentType: "application/x-vnd-json",
+	}
+
+	validator := jsonschema.Validator{}
+	require.NoError(t, validator.AddSchema(
+		rest.ParamInHeader,
+		"X-Name",
+		[]byte(`{"type":"string","minLength":3}`),
+		false),
+	)
+
+	ht.RespValidator = &validator
+
+	e.SetupOutput(outputPort{}, &ht)
+
+	r, err := http.NewRequest(http.MethodGet, "/", nil)
+	require.NoError(t, err)
+
+	w := httptest.NewRecorder()
+	output := e.MakeOutput(w, ht)
+
+	out, ok := output.(*outputPort)
+	assert.True(t, ok)
+
+	out.Name = "Jane"
+	out.Items = []string{"one", "two", "three"}
+
+	e.WriteSuccessfulResponse(w, r, output, ht)
+	assert.Equal(t, http.StatusOK, w.Code)
+	assert.Equal(t, "Jane", w.Header().Get("X-Name"))
+	assert.Equal(t, "application/x-vnd-json", w.Header().Get("Content-Type"))
+	assert.Equal(t, "32", w.Header().Get("Content-Length"))
+	assert.Equal(t, `{"items":["one","two","three"]}`+"\n", w.Body.String())
+}