在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:koajs/koa-range开源软件地址:https://github.com/koajs/koa-range开源编程语言:JavaScript 93.1%开源软件介绍:koa-rangerange request implementation for koa Installation$ npm install koa-range Usage (with koa@2)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:
LicenseMIT |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论