File tree Expand file tree Collapse file tree 4 files changed +21
-11
lines changed
Expand file tree Collapse file tree 4 files changed +21
-11
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,8 @@ For other examples, see `example.js`.
6565
6666## Options
6767
68- This ` fastify ` plugin supports the following options.
68+ This ` fastify ` plugin supports _ all_ the options of
69+ [ ` fastify-reply-from ` ] ( https://github.com/fastify/fastify-reply-from ) plus the following.
6970
7071* Note that this plugin is fully encapsulated, and non-JSON payloads will
7172be streamed directly to the destination.*
@@ -82,10 +83,6 @@ The prefix to mount this plugin on. All the requests to the current server start
8283
8384A ` beforeHandler ` to be applied on all routes. Useful for performing actions before the proxy is executed (e.g. check for authentication).
8485
85- ### http2
86-
87- A boolean value that indicates whether the proxy should support http2.
88-
8986## Benchmarks
9087
9188The following benchmarks where generated on a Macbook 2018 with i5 and
@@ -95,6 +92,8 @@ The following benchmarks where generated on a Macbook 2018 with i5 and
9592| ` express-http-proxy ` | 878.4 |
9693| ` http-proxy ` | 3837 |
9794| ` fastify-http-proxy ` | 4205 |
95+ | ` fastify-http-proxy ` (with
96+ [ ` undici ` ] ( https://github.com/mcollina/undici ) ) | 6235.6 |
9897
9998The results where gathered on the second run of `autocannon -c 100 -d 5
10099URL`.
Original file line number Diff line number Diff line change @@ -5,9 +5,19 @@ const proxy = require('..')
55
66async function startProxy ( upstream ) {
77 const server = Fastify ( )
8+ let undici = false
9+
10+ if ( process . env . UNDICI ) {
11+ undici = {
12+ connections : 100 ,
13+ pipelining : 10
14+ }
15+ }
16+
817 server . register ( proxy , {
918 upstream,
10- http2 : ! ! process . env . HTTP2
19+ http2 : ! ! process . env . HTTP2 ,
20+ undici
1121 } )
1222
1323 await server . listen ( 3000 )
Original file line number Diff line number Diff line change @@ -9,10 +9,11 @@ module.exports = async function (fastify, opts) {
99
1010 const beforeHandler = opts . beforeHandler
1111
12- fastify . register ( From , {
13- base : opts . upstream ,
14- http2 : opts . http2
15- } )
12+ const fromOpts = Object . assign ( { } , opts )
13+ fromOpts . base = opts . upstream
14+ fromOpts . prefix = undefined
15+
16+ fastify . register ( From , fromOpts )
1617
1718 fastify . addContentTypeParser ( 'application/json' , bodyParser )
1819 fastify . addContentTypeParser ( '*' , bodyParser )
Original file line number Diff line number Diff line change 3636 "tap" : " ^12.0.0"
3737 },
3838 "dependencies" : {
39- "fastify-reply-from" : " ^0.4.5 "
39+ "fastify-reply-from" : " ^0.5.0 "
4040 }
4141}
You can’t perform that action at this time.
0 commit comments