Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

「评论」koa源码:架构设计 #133

Open
dongyuanxin opened this issue Jun 18, 2019 · 5 comments
Open

「评论」koa源码:架构设计 #133

dongyuanxin opened this issue Jun 18, 2019 · 5 comments

Comments

@dongyuanxin
Copy link
Owner

koa源码:架构设计:https://xin-tan.com/passages/2019-06-18-deep-in-koa/

@theniceangel
Copy link

theniceangel commented Jun 25, 2019

ctx.headers 访问的是 ctx.reqeust 上的 headers

这一处有笔误。应该是 ctx.request。

ctx.headers 代理 ctx.res.headers

感觉这一块说的不是很清晰。按照逻辑的流向应该是 ctx.headers 求值是先执行 ctx.request.headers,而 ctx.request.headers 的求值是执行 this.req.headers,当前的 this 指向的是 request,最后也就是 request.req.headers,request.req 就是请求的 request,这样就拿到浏览器传过来的 headers 了。

@dongyuanxin
Copy link
Owner Author

dongyuanxin commented Jun 26, 2019

@theniceangel

Thanks♪(・ω・)ノ,笔误已修改,关于 ctx.headers 那部分也重新写了下。文中实名感谢老哥,哈哈

@theniceangel
Copy link

@dongyuanxin 之前就一直关注你了,感觉你还是特别能折腾,算是志同道合吧,要是你在北京,可以内推你到我们组😊

@theniceangel
Copy link

还有就是觉得 koa 的源码你可以写的再详细点,比如 koa-compose 为啥要这么实现,可以画图解释下洋葱模型。

@dongyuanxin
Copy link
Owner Author

@theniceangel
还有就是觉得 koa 的源码你可以写的再详细点,比如 koa-compose 为啥要这么实现,可以画图解释下洋葱模型。

洋葱模型网上有好多,就没有再画图了。有时候顺着思路就写下去了,就没有那么细致

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants