responses

Edit

pre-define the format of router return.

for example return json contain code 200 and result:

1
2
3
4
5
6
7
export default function Ok(ctx, data){
ctx.status = 200;
ctx.body = {
code : 200,
result : data
};
}

or return the format of list data:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
export default function List(ctx, {data, page, page_count, total_count}){
ctx.status = 200;
ctx.body = {
code : 200,
result : {
list : data,
_metadata: {
page: 51,
page_count: 20,
total_count: 521
}
}
};
}