@@ -11,26 +11,24 @@ app.prepare()
1111 const server = new Koa ( )
1212 const router = new Router ( )
1313
14- router . get ( '/a' , function * ( ) {
15- app . render ( this . req , this . res , '/b' , this . query )
16- this . respond = false
14+ router . get ( '/a' , async ctx => {
15+ await app . render ( ctx . req , ctx . res , '/b' , ctx . query )
16+ ctx . respond = false
1717 } )
1818
19- router . get ( '/b' , function * ( ) {
20- app . render ( this . req , this . res , '/a' , this . query )
21- this . respond = false
19+ router . get ( '/b' , async ctx => {
20+ await app . render ( ctx . req , ctx . res , '/a' , ctx . query )
21+ ctx . respond = false
2222 } )
2323
24- router . get ( '*' , function * ( ) {
25- handle ( this . req , this . res )
26- this . respond = false
24+ router . get ( '*' , async ctx => {
25+ await handle ( ctx . req , ctx . res )
26+ ctx . respond = false
2727 } )
2828
29- server . use ( function * ( next ) {
30- // Koa doesn't seems to set the default statusCode.
31- // So, this middleware does that
32- this . res . statusCode = 200
33- yield next
29+ server . use ( async ( ctx , next ) => {
30+ ctx . res . statusCode = 200
31+ await next ( )
3432 } )
3533
3634 server . use ( router . routes ( ) )
0 commit comments