Skip to content

Commit

Permalink
doc: Add example for Koa@2
Browse files Browse the repository at this point in the history
closes #42
  • Loading branch information
niieani authored and haoxin committed Dec 7, 2015
1 parent f0d9c03 commit 35cced5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,25 @@ app.use(function *(){
})
```

## Example (Koa@2) with async/await

```js
var send = require('koa-send');
var Koa = require('koa');
var app = new Koa();

// $ GET /package.json
// $ GET /

app.use(async function (ctx, next){
if ('/' == ctx.path) return ctx.body = 'Try GET /package.json';
await send(ctx, __dirname + '/package.json');
})

app.listen(3000);
console.log('listening on port 3000');
```

## Example

```js
Expand Down

0 comments on commit 35cced5

Please sign in to comment.