项目作者: serviejs

项目描述 :
General HTTP request body parser
高级语言: TypeScript
项目地址: git://github.com/serviejs/get-body.git
创建时间: 2017-01-24T21:29:36Z
项目社区:https://github.com/serviejs/get-body

开源协议:Other

下载


Get Body

NPM version
NPM downloads
Build status
Test coverage

General HTTP request body parser.

Looking for a multipart body parser? Try busboy.

Installation

  1. npm install get-body --save

Usage

  1. import { parse, json, text, form } from 'get-body'
  2. import { createServer } from 'http'
  3. createServer(function (req) {
  4. parse(req, req.headers).then(body => console.log(body))
  5. })

Arguments

  1. stream: Readable An instance of the request stream
  2. headers: object The raw headers object as a lower-cased map
  3. options: object Parser configuration

Options

  • limit Controls the maximum request body size (default: 100kb).
  • decoders Map of known content-encoding decoders (default: exports.decoders)
  • jsonParse Custom behaviour for JSON parsing (default: strict JSON.parse check)
  • formParse Custom behaviour for form parsing (default: querystring.parse)
  • jsonTypes Array of media types to parse as JSON
  • formTypes Array of media types to parse as a form
  • textTypes Array of media types to parse as text

TypeScript

This project is written using TypeScript and publishes the definitions directly to NPM.

License

Apache 2.0