Skip to Content
Node与Express开发(第2版)
book

Node与Express开发(第2版)

by Ethan Brown
June 2021
Intermediate to advanced
290 pages
9h 21m
Chinese
Posts & Telecom Press
Content preview from Node与Express开发(第2版)
request
和
response
对象
|
59
6.9
 深入源代码
由于
JavaScript
是一种原型继承的语言,要完全理解正在使用的对象有时候是一个挑战。
Node
提供的对象会经过
Express
的扩展
,而你增加的包也会扩展那些对象。想要清楚地知
道对象有什么属性和方法可用有时候并不容易。通常我推荐反向操作:如果要寻找某个功
能,首先检查
Express API
文
档。
Express API
文档相当完整,很多时候我们能从里面找到
所需。
如果文档里没有想要的信息,有时候就得深入
Express
源代码
。我十分鼓励你深入源代码,
因为你很可能会发现,读源代码远没有想象的那般令人头疼。下面是一个快速导航,据此
可以从
Express
源代码里查找想要的东西。
lib/application.js
这是
Express
的主要接口
。如果想理解中间件是怎么链接起来的或视图是怎么渲染的,
就需要读这个文件。
lib/express.js
一个相对短小的文件,主要提供了
createApplication
函数(这个文件的默认导出),这
个函数用于创建
Express
应用的一个实例。
lib/request.js
扩展
Node
的
http.IncomingMessage
对象,从而提供一个健壮的
request
对象。这个文件
包含
request
对象所有的属性和方法。
lib/response.js
扩展
Node
的
http.ServerResponse
对象,从而提供
response
对象。这个文件包含
response
对象的属性和方法。
lib/router/route.js ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

面向对象的思考过程(原书第5版)

面向对象的思考过程(原书第5版)

马特 魏斯费尔德
精通模块化JavaScript

精通模块化JavaScript

Nicolás Bevacqua

Publisher Resources

ISBN: 9787115565099