在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称:wejendorp/koa-timeout开源软件地址:https://github.com/wejendorp/koa-timeout开源编程语言:JavaScript 100.0%开源软件介绍:koa-timeoutTimeout middleware for koa. Will throw "Request timeout" (Http 408) for any requests that take too long. Installation
ExampleIf we always want to respond within half a second, we could use var koa = require('koa');
var timeout = require('koa-timeout')(500);
var app = koa();
app.use(function * tryCatch(next) {
try {
yield next;
} catch(e) {
this.status = e.status || 500;
this.body = e.message;
}
});
app.use(timeout);
// Some potentially slow logic:
app.use(function * () {
yield function(done) {
setTimeout(done, 1000);
};
});
app.listen(3000); LicenseMIT |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论