@fastify/reply-from
Advanced tools
Comparing version 8.4.3 to 9.0.0
@@ -66,3 +66,3 @@ 'use strict' | ||
// we leverage caching to avoid parsing the destination URL | ||
const dest = getUpstream(req, base) | ||
const dest = getUpstream(this.request, base) | ||
let url | ||
@@ -140,3 +140,3 @@ if (cache) { | ||
const requestHeaders = rewriteRequestHeaders(req, headers) | ||
const requestHeaders = rewriteRequestHeaders(this.request, headers) | ||
const contentLength = requestHeaders['content-length'] | ||
@@ -171,7 +171,7 @@ let requestImpl | ||
copyHeaders( | ||
rewriteHeaders(stripHttp1ConnectionHeaders(res.headers), req), | ||
rewriteHeaders(stripHttp1ConnectionHeaders(res.headers), this.request), | ||
this | ||
) | ||
} else { | ||
copyHeaders(rewriteHeaders(res.headers, req), this) | ||
copyHeaders(rewriteHeaders(res.headers, this.request), this) | ||
} | ||
@@ -178,0 +178,0 @@ this.code(res.statusCode) |
{ | ||
"name": "@fastify/reply-from", | ||
"version": "8.4.3", | ||
"version": "9.0.0", | ||
"description": "forward your HTTP request to another server, for fastify", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -295,17 +295,20 @@ # @fastify/reply-from | ||
#### `rewriteHeaders(headers, req)` | ||
#### `rewriteHeaders(headers, request)` | ||
Called to rewrite the headers of the response, before them being copied | ||
over to the outer response. | ||
Parameters are the original headers and the Fastify request. | ||
It must return the new headers object. | ||
#### `rewriteRequestHeaders(originalReq, headers)` | ||
#### `rewriteRequestHeaders(request, headers)` | ||
Called to rewrite the headers of the request, before them being sent to the other server. | ||
Parameters are the Fastify request and the original request headers. | ||
It must return the new headers object. | ||
#### `getUpstream(originalReq, base)` | ||
#### `getUpstream(request, base)` | ||
Called to get upstream destination, before the request is being sent. Useful when you want to decide which target server to call based on the request data. | ||
Helpful for a gradual rollout of new services. | ||
Parameters are the Fastify request and the base string from the plugin options. | ||
It must return the upstream destination. | ||
@@ -312,0 +315,0 @@ |
@@ -14,3 +14,2 @@ /// <reference types="node" /> | ||
import { | ||
IncomingMessage, | ||
IncomingHttpHeaders, | ||
@@ -27,3 +26,2 @@ RequestOptions, | ||
import { | ||
Http2ServerRequest, | ||
IncomingHttpHeaders as Http2IncomingHttpHeaders, | ||
@@ -64,10 +62,10 @@ ClientSessionRequestOptions, | ||
headers: Http2IncomingHttpHeaders | IncomingHttpHeaders, | ||
req?: Http2ServerRequest | IncomingMessage | ||
request?: FastifyRequest<RequestGenericInterface, RawServerBase> | ||
) => Http2IncomingHttpHeaders | IncomingHttpHeaders; | ||
rewriteRequestHeaders?: ( | ||
req: Http2ServerRequest | IncomingMessage, | ||
request: FastifyRequest<RequestGenericInterface, RawServerBase>, | ||
headers: Http2IncomingHttpHeaders | IncomingHttpHeaders | ||
) => Http2IncomingHttpHeaders | IncomingHttpHeaders; | ||
getUpstream?: ( | ||
req: Http2ServerRequest | IncomingMessage, | ||
request: FastifyRequest<RequestGenericInterface, RawServerBase>, | ||
base: string | ||
@@ -74,0 +72,0 @@ ) => string; |
import replyFrom, { FastifyReplyFromOptions } from ".."; | ||
import fastify, {FastifyReply, RawServerBase} from "fastify"; | ||
import fastify, {FastifyReply, FastifyRequest, RawServerBase, RequestGenericInterface} from "fastify"; | ||
import { AddressInfo } from "net"; | ||
@@ -8,3 +8,2 @@ import { IncomingHttpHeaders } from "http2"; | ||
import * as https from 'https'; | ||
import * as http2 from 'http2'; | ||
// @ts-ignore | ||
@@ -71,7 +70,7 @@ import tap from 'tap' | ||
rewriteRequestHeaders(req, headers) { | ||
expectType<http.IncomingMessage | http2.Http2ServerRequest>(req); | ||
expectType<FastifyRequest<RequestGenericInterface, RawServerBase>>(req); | ||
return headers; | ||
}, | ||
getUpstream(req, base) { | ||
expectType<http.IncomingMessage | http2.Http2ServerRequest>(req); | ||
expectType<FastifyRequest<RequestGenericInterface, RawServerBase>>(req); | ||
return base; | ||
@@ -78,0 +77,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
169086
102
5020
377
69