{"action":"created","issue":{"url":"https://api.github.com/repos/koajs/koa/issues/564","labels_url":"https://api.github.com/repos/koajs/koa/issues/564/labels{/name}","comments_url":"https://api.github.com/repos/koajs/koa/issues/564/comments","events_url":"https://api.github.com/repos/koajs/koa/issues/564/events","html_url":"https://github.com/koajs/koa/issues/564","id":113826848,"number":564,"title":"Broken middleware since 2.0.0","user":{"login":"rbaprado","id":9011953,"avatar_url":"https://avatars.githubusercontent.com/u/9011953?v=3","gravatar_id":"","url":"https://api.github.com/users/rbaprado","html_url":"https://github.com/rbaprado","followers_url":"https://api.github.com/users/rbaprado/followers","following_url":"https://api.github.com/users/rbaprado/following{/other_user}","gists_url":"https://api.github.com/users/rbaprado/gists{/gist_id}","starred_url":"https://api.github.com/users/rbaprado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbaprado/subscriptions","organizations_url":"https://api.github.com/users/rbaprado/orgs","repos_url":"https://api.github.com/users/rbaprado/repos","events_url":"https://api.github.com/users/rbaprado/events{/privacy}","received_events_url":"https://api.github.com/users/rbaprado/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-10-28T13:57:53Z","updated_at":"2015-10-28T14:15:07Z","closed_at":null,"body":"Hello, I just upgraded to Koa 2.0.0 and due to the generator support dropping, all my middleware simply broke (i.e. koa-session). I tried co.wrap them but got other errors (I will provide more information shortly). Could someone please present an example of using middleware not yet ported to 2.0.0?\r\n\r\nOriginal code:\r\n`app.use((session(app));`\r\n\r\nMy attempt:\r\n`app.use(co.wrap(session(app)));`"},"comment":{"url":"https://api.github.com/repos/koajs/koa/issues/comments/151858184","html_url":"https://github.com/koajs/koa/issues/564#issuecomment-151858184","issue_url":"https://api.github.com/repos/koajs/koa/issues/564","id":151858184,"user":{"login":"madbence","id":296735,"avatar_url":"https://avatars.githubusercontent.com/u/296735?v=3","gravatar_id":"","url":"https://api.github.com/users/madbence","html_url":"https://github.com/madbence","followers_url":"https://api.github.com/users/madbence/followers","following_url":"https://api.github.com/users/madbence/following{/other_user}","gists_url":"https://api.github.com/users/madbence/gists{/gist_id}","starred_url":"https://api.github.com/users/madbence/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/madbence/subscriptions","organizations_url":"https://api.github.com/users/madbence/orgs","repos_url":"https://api.github.com/users/madbence/repos","events_url":"https://api.github.com/users/madbence/events{/privacy}","received_events_url":"https://api.github.com/users/madbence/received_events","type":"User","site_admin":false},"created_at":"2015-10-28T14:15:07Z","updated_at":"2015-10-28T14:15:07Z","body":"in `koa@2` the context is an arg, so you write your middlewares like `async (ctx, next) => ...`, `co.wrap` just wraps your `function* (next) {...}` middleware into an `async (next) => ...`, so it won't work.\r\n\r\nyou *can* use generators, if the have proper signature (`function* (ctx, next) { ... }`)"}}