请求和响应
Express应用使用回调函数的参数: request和response对象来处理请求和响应的数据。
app.get('/', function (req, res) {
   // --
})
request和response对象的具体介绍:
Request 对象 - request对象表示HTTP请求,包含了请求查询字符串,参数,内容,HTTP头部等属性。常见属性有:
| 1. | req.app:当callback为外部文件时,用req.app访问express的实例 | 
| 2. | req.baseUrl:获取路由当前安装的URL路径 | 
| 3. | req.body / req.cookies:获得「请求主体」/ Cookies | 
| 4. | req.fresh / req.stale:判断请求是否还「新鲜」 | 
| 5. | req.hostname / req.ip:获取主机名和IP地址 | 
| 6. | req.originalUrl:获取原始请求URL | 
| 7. | req.params:获取路由的parameters | 
| 8. | req.path:获取请求路径 | 
| 9. | req.protocol:获取协议类型 | 
| 10. | req.query:获取URL的查询参数串 | 
| 11. | req.route:获取当前匹配的路由 | 
| 12. | req.subdomains:获取子域名 | 
| 13. | req.accpets():检查请求的Accept头的请求类型 | 
| 14. | req.acceptsCharsets / req.acceptsEncodings / req.acceptsLanguages | 
| 15. | req.get():获取指定的HTTP请求头 | 
| 16. | req.is():判断请求头Content-Type的MIME类型 | 
Response 对象 - response对象表示HTTP响应,即在接收到请求时向客户端发送的HTTP响应数据。常见属性有:
| 1. | res.app:当callback为外部文件时,用req.app访问express的实例 | 
| 2. | res.append():追加指定HTTP头 | 
| 3. | res.set()在res.append()后将重置之前设置的头 | 
| 4. | res.cookie(name,value [,option]):设置Cookie | 
| 5. | opition: domain / expires / httpOnly / maxAge / path / secure / signed | 
| 6. | res.clearCookie():清除Cookie | 
| 7. | res.download():传送指定路径的文件 | 
| 8. | res.get():返回指定的HTTP头 | 
| 9. | res.json():传送JSON响应 | 
| 10. | res.jsonp():传送JSONP响应 | 
| 11. | res.location():只设置响应的Location HTTP头,不设置状态码或者close response | 
| 12. | res.redirect():设置响应的Location HTTP头,并且设置状态码302 | 
| 13. | res.send():传送HTTP响应 | 
| 14. | res.sendFile(path [,options] [,fn]): 传送指定路径的文件 -会自动根据文件extension设定Content-Type
 | 
| 15. | res.set():设置HTTP头,传入object可以一次设置多个头 | 
| 16. | res.status():设置HTTP状态码 | 
| 17. | res.type():设置Content-Type的MIME类型 |