Skip to content

keq-headers

Provide Middleware for modifying HTTP request headers.

Usage

typescript
import { request } from 'keq'
import {
  setHeader,
  setHeaders,
  appendHeader,
  appendHeaders,
  insertHeader,
  insertHeaders,
} from 'keq-headers'


request
  .use(setHeader('x-user-name', 'Kerry'))
  .use(appendHeader('x-user-name', 'Marry'))
  .use(insertHeader('x-user-name', 'J'))
  .use(setHeaders({
    'x-user-name': 'Kerry',
    'x-user-id': '1'
  }))
  .use(appendHeaders({
    'x-user-name': 'Marray',
    'x-user-id': '1',
  }))
  .use(insertHeaders({
    'x-user-name': 'J',
    'x-user-id': 1,
  }))
MiddlewareDescription
setHeaderSet a header.If it already exists, the original value will be overwritten.
setHeadersSet headers.If it already exists, the original value will be overwritten.
appendHeaderAppend a header.
appendHeadersAppend headers.
insertHeaderSet a header, if it isn't existed.
insertHeadersSet headers, if it isn't existed.