2.1.0 • Published 7 years ago

koa-response v2.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

koa-response

Response Middleware for koajs

npm

Installation

$ npm install koa-response

Usage

const app = require('koa')();
const response = require('koa-response');

app.use(response((responsed) => {console.log(responsed.method,request.body)}));

app.use(function *(next){
  this.throw(200,success);
});

API

this.throw(status,data/error,isjson);

  - status: 状态码,400以下为成功
  - data/error: 返回的数据/错误
      - 当返回失败(status>=400 || status === false),且没有指定error时,默认返回默认错误
  - isjson: 是否已json格式返回,默认true
      - false时返回类似nginx错误的html
2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0-alpha.1

7 years ago

1.0.4

7 years ago

2.0.0

7 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago