1.3.2 • Published 1 year ago
koa-auto-transfer-header v1.3.2
koa-auto-transfer-header
In a Koa server, when a client request is received and an external HTTP request is initiated in the request, the request header initiated by the client is automatically forwarded.
Also used in a server started from any Web Framework.
Support all http-client libs based on http module.
Installation
npm install koa-auto-transfer-header [--save]
or
yarn add koa-auto-transfer-headerUsage
import in portal file
import 'koa-auto-transfer-header';Config
interface IConfig {
enable: boolean; // is enable tranfer, default: true
transferHeaders: string[], // transfer header keys, default: ['request-id', 'trace-id']
}disable transfer
import { disableTransferHeaders } from 'koa-auto-transfer-header';
disableTransferHeaders();add transfer header
import { addTransferHeader } from 'koa-auto-transfer-header';
addTransferHeader('my-header');reset transfer headers
import { setTransferHeaders } from 'koa-auto-transfer-header';
setTransferHeaders(['my-header1', 'my-header2']);add request headers hook
import { RequestHeadersHook } from 'koa-auto-transfer-header';
const foo = () => {
return { 'x-headers-foo': '123' }
}
const bar = () => {
return { 'x-headers-bar': '123' }
}
RequestHeadersHook.register(foo)
RequestHeadersHook.register(bar)
// cancel the register
RequestHeadersHook.unregister(foo)1.3.2
1 year ago
1.2.0
2 years ago
1.2.4
2 years ago
1.2.3
2 years ago
1.3.1
1 year ago
1.2.2
2 years ago
1.3.0
1 year ago
1.2.1
2 years ago
1.1.3
2 years ago
1.1.1
2 years ago
1.1.0
2 years ago
1.1.2
2 years ago
1.0.6
2 years ago
1.0.5
2 years ago
1.0.4
3 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago