{"action":"opened","issue":{"url":"https://api.github.com/repos/pengliheng/pengliheng.github.io/issues/16","repository_url":"https://api.github.com/repos/pengliheng/pengliheng.github.io","labels_url":"https://api.github.com/repos/pengliheng/pengliheng.github.io/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/pengliheng/pengliheng.github.io/issues/16/comments","events_url":"https://api.github.com/repos/pengliheng/pengliheng.github.io/issues/16/events","html_url":"https://github.com/pengliheng/pengliheng.github.io/issues/16","id":310302780,"number":16,"title":"koa 源码阅读","user":{"login":"pengliheng","id":14355994,"avatar_url":"https://avatars2.githubusercontent.com/u/14355994?v=4","gravatar_id":"","url":"https://api.github.com/users/pengliheng","html_url":"https://github.com/pengliheng","followers_url":"https://api.github.com/users/pengliheng/followers","following_url":"https://api.github.com/users/pengliheng/following{/other_user}","gists_url":"https://api.github.com/users/pengliheng/gists{/gist_id}","starred_url":"https://api.github.com/users/pengliheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pengliheng/subscriptions","organizations_url":"https://api.github.com/users/pengliheng/orgs","repos_url":"https://api.github.com/users/pengliheng/repos","events_url":"https://api.github.com/users/pengliheng/events{/privacy}","received_events_url":"https://api.github.com/users/pengliheng/received_events","type":"User","site_admin":false},"labels":[{"id":818989463,"url":"https://api.github.com/repos/pengliheng/pengliheng.github.io/labels/%E5%8D%9A%E5%AE%A2","name":"博客","color":"d9fcae","default":false},{"id":875837454,"url":"https://api.github.com/repos/pengliheng/pengliheng.github.io/labels/%E6%A1%86%E6%9E%B6","name":"框架","color":"49d8ad","default":false}],"state":"open","locked":false,"assignee":{"login":"pengliheng","id":14355994,"avatar_url":"https://avatars2.githubusercontent.com/u/14355994?v=4","gravatar_id":"","url":"https://api.github.com/users/pengliheng","html_url":"https://github.com/pengliheng","followers_url":"https://api.github.com/users/pengliheng/followers","following_url":"https://api.github.com/users/pengliheng/following{/other_user}","gists_url":"https://api.github.com/users/pengliheng/gists{/gist_id}","starred_url":"https://api.github.com/users/pengliheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pengliheng/subscriptions","organizations_url":"https://api.github.com/users/pengliheng/orgs","repos_url":"https://api.github.com/users/pengliheng/repos","events_url":"https://api.github.com/users/pengliheng/events{/privacy}","received_events_url":"https://api.github.com/users/pengliheng/received_events","type":"User","site_admin":false},"assignees":[{"login":"pengliheng","id":14355994,"avatar_url":"https://avatars2.githubusercontent.com/u/14355994?v=4","gravatar_id":"","url":"https://api.github.com/users/pengliheng","html_url":"https://github.com/pengliheng","followers_url":"https://api.github.com/users/pengliheng/followers","following_url":"https://api.github.com/users/pengliheng/following{/other_user}","gists_url":"https://api.github.com/users/pengliheng/gists{/gist_id}","starred_url":"https://api.github.com/users/pengliheng/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pengliheng/subscriptions","organizations_url":"https://api.github.com/users/pengliheng/orgs","repos_url":"https://api.github.com/users/pengliheng/repos","events_url":"https://api.github.com/users/pengliheng/events{/privacy}","received_events_url":"https://api.github.com/users/pengliheng/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2018-04-01T06:51:58Z","updated_at":"2018-04-01T06:51:58Z","closed_at":null,"author_association":"OWNER","body":"### 为什么是koa而不是express呢？\r\n- koa更小\r\n\r\n![image](https://user-images.githubusercontent.com/14355994/38170547-168a4ec2-35bb-11e8-826f-4ba6f0bd5bf7.png)\r\n- 易于理解的源码结构\r\n主线结构application用于构造整个koa，content.js用于构造ctx，request用于重写req，response用于重写res\r\n\r\n![image](https://user-images.githubusercontent.com/14355994/38170554-49c78656-35bb-11e8-82fc-b4f840bc9f23.png)\r\n![image](https://user-images.githubusercontent.com/14355994/38170580-103242b8-35bc-11e8-84d6-bb9cb0b3f592.png)\r\n\r\n- 基于es7的async/await的中间件调用机制\r\n```js\r\nclass koa{\r\n  constructor(){\r\n    this.middleware = []; //存放中间件\r\n  }\r\n}\r\n```\r\n- 重写req与res"}}
{"actor":{"display_login":"pengliheng"}}