Body parsing plugin for YAPS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

1.1 KiB

YAPS Body Parser

A body parsing plugin for YAPS.

Install

Via NPM

npm install [-g] yaps-body

Via Git

git clone git://github.com/brettlangdon/yaps-body.git
cd ./yaps-body
npm install
``

## Usage
```javascript
var yaps = require("yaps");

var yaps_body = require("yaps-body");

var app = new yaps.server();
app.registerPlugin(yaps_body);

var my_plugin = function(options){
    this.POST("/", function(request, server, respond){
        // the request body as a buffer
        console.dir(request.body);
        // any errors raised while reading the POST data
        console.dir(request.bodyError);
        respond(200, "");
    });
};

app.registerPlugin(my_plugin);
app.start();

Settings

var yaps = require("yaps");

var yaps_body = require("yaps-body");

var app = new yaps.server({
    // attempt to parse the body as JSON, default: false
    // this means request.body will be an obj and NOT a buffer
    bodyAsJSON: true,
});
app.registerPlugin(yaps_body);

app.start();