koa-request-xhr
v1.0.1
Published
Express req.xhr equivalent for koa
Downloads
20
Readme
koa-request-xhr
This middleware simply sets a xhr
boolean on the koa request.
This aims to be the equivalent of Express req.xhr
Installation
$ npm install koa-request-xhr --save
Example
var koa = require('koa');
var xhr = require('koa-request-xhr');
var app = koa();
app.use(xhr());
app.use(function *(){
if (this.request.xhr) {
this.body = { message: 'Hello World' };
} else {
this.body = 'Hello World';
}
});
app.listen(3000);