![]() | Name | Last modified | Size | Description |
---|---|---|---|---|
![]() | Parent Directory | - | ||
![]() | test/ | 2 years ago | - | |
![]() | Makefile | 8 years ago | 581 | |
![]() | README.md | 8 years ago | 1.9K | |
![]() | index.js | 8 years ago | 2.3K | |
![]() | package.json | 2 years ago | 1.6K |
range request implementation for koa
$ npm install koa-range
var fs = require('fs');
var range = require('koa-range');
var route = require('koa-route');
var Koa = require('koa');
var app = new Koa();
app.use(range);
// via buffer
app.use(route.get('/', async function (ctx) {
ctx.body = new Buffer(100);
}));
// via object
app.use(route.get('/json', async function (ctx) {
ctx.body = {
'foo': 'bar'
};
}));
// via readable stream
app.use(route.get('/stream', async function (ctx) {
ctx.body = fs.createReadStream('your path');
}));
Until async/await is supported by default, you will need to do one of the following:
MIT