Skip to content

Commit aaaf86d

Browse files
authored
Merge pull request #28 from jkyberneees/minor-onResponse-hook-refactoring
Minor on response hook refactoring
2 parents 02be716 + 5363bb0 commit aaaf86d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ For developers reference, next we describe how the default `onResponse` hook loo
109109
```js
110110
const pump = require('pump')
111111
const toArray = require('stream-to-array')
112+
const TRANSFER_ENCODING_HEADER_NAME = 'transfer-encoding'
112113

113114
const onResponse = async (req, res, stream) => {
114-
const TRANSFER_ENCODING_HEADER_NAME = 'transfer-encoding'
115115
const chunked = stream.headers[TRANSFER_ENCODING_HEADER_NAME]
116116
? stream.headers[TRANSFER_ENCODING_HEADER_NAME].endsWith('chunked')
117117
: false

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const toArray = require('stream-to-array')
77
const defaultProxyHandler = (req, res, url, proxy, proxyOpts) => proxy(req, res, url, proxyOpts)
88
const DEFAULT_METHODS = require('restana/libs/methods').filter(method => method !== 'all')
99
const send = require('@polka/send-type')
10+
const TRANSFER_ENCODING_HEADER_NAME = 'transfer-encoding'
1011

1112
const gateway = (opts) => {
1213
opts = Object.assign({
@@ -103,7 +104,6 @@ const handler = (route, proxy, proxyHandler) => async (req, res, next) => {
103104

104105
const onRequestNoOp = (req, res) => { }
105106
const onResponse = async (req, res, stream) => {
106-
const TRANSFER_ENCODING_HEADER_NAME = 'transfer-encoding'
107107
const chunked = stream.headers[TRANSFER_ENCODING_HEADER_NAME]
108108
? stream.headers[TRANSFER_ENCODING_HEADER_NAME].endsWith('chunked')
109109
: false

0 commit comments

Comments
 (0)