sunkuo / grow-to-express Goto Github PK
View Code? Open in Web Editor NEW渐进式Express学习课程,从零开始实现一个Express
渐进式Express学习课程,从零开始实现一个Express
图层挂了朋友。。。
this.route.dispatch.apply(this.route, slice.call(arguments))
this.route.dispatch(arguments)
这两种写法应该等价的为什么要用上面那种?
跟着Lesson一路写下来:到Lesson3时,写的代码大致差不多。(只不过我用了更多es6语法而已,无伤大雅)但到Lesson4的时候,第一感觉就是博主实现的是不是过于臃肿了?(没有看express源码,有这样的疑问),不就是跟Lesson3一样,只不过引入了path进来了吗?于是我只改了有关path的部分,也能跑起来。
我的Lesson3: https://github.com/shenjo/express-study/blob/master/src/router.js
Router.js
Lesson 4 Router.js(还没提交到github上)
区别在与使用时,app.get('/',fn1,fn2) 第一个参数都是path了,后续的参数才是function。
所以我不太明白index.js(我感觉又是跟Router一样的东西)存在的意义。
大概跟着lesson写了一遍,对于express逐渐有了理解,然而提纲中的部分问题貌似没有涉及到?
比如:
严格路由和不严格路由有什么区别
如何设置路由不敏感或严格路由
trust proxy什么用
Etag weak 和strong有什么区别
app.all和app.use的区别及性能差异
个人认为带着这些问题跟随lesson效率会更高一些,但是coding的过程中发现代码没有体现以上这些知识点?
this.method 应该不需要toLowerCase
函数
因为 methods 库已经放的是http方法的小写单词了
请问不知道您这样写是什么用意?
您好,
app.get('/order/:type/:state', fn)
app.param('type', handle1, handle2)
app.param('state', handle3)
這部分
app.param('type', handle1, handle2)
是不是要改成
app.param('type', handle1)
app.param('type', handle2)
會比較好?
因為我自己看程式碼裡面
應該沒辦法做到一次傳兩個handle
但不確定是不是我理解程式有誤
麻煩您解惑了
謝謝!
受益良多,謝謝
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.