Express 3.0是一个维护版本,针对2.x版修复了很多问题,并加入了很多新功能。
在使用Express框架时,要记住,Express框架是帮助开发者快速实现HTTP通信相关的功能,而不是成为像Rails那样功能强大、全面的框架。Connect 2.xChanges introduced by Connect 2.x:added err.status support to Connect’s default end-pointadded session() “proxy” setting to trust “X-Forwarded-Proto”added cookieSession() middlewareadded compress() middleware for gzipped responsesadded multipart() middlewareadded json() middlewareadded urlencoded() middlewareadded limit option to the three above middlewareadded defer option to multipart() to listen on formidable’s eventsadded debug() instrumentation to aid in debuggingchanged basicAuth()’s req.remoteUser to req.userchanged session() to only set-cookie on modification (hashed session json)changed bodyParser() to be an aggregate of json(), multipart() and urlencoded()moved many cookie-related utils into npmmoved static()’s logic into a separate npm module named “send”increase perf ~%20 by memoizing url parsingremoved router() middlewarefixed default encoding for logger(), now “utf8” instead of “ascii”fixed mount-path case-sensitivityConnect docs are available at http://www.senchalabs.org/connect/, and will eventually be mirrored on expressjs.com as well for convenience, along with usage guides.
作者:chszs,转载需注明。作者博客主页:http://blog.csdn.net/chszs
Express 3.x
Changes introduced by Express 3.x:added several new examples in ./examplesadded unit testing for the examples (most of them at least)added res.jsonp() to explicitly opt-in to JSONP supportadded ETags and conditional-GET handling to res.send() responsesadded “jsonp callback name” settingadded support for status code as first or second arg to res.send() and res.redirect()added req.range(size) to parse Range header fieldsadded req.auth for basic authadded res.links(obj) to set response the Link header field for paginationadded res.format(obj) for content-negotiationadded req.fresh for conditional-GETsadded req.stale for conditional-GETsadded mount-point relative redirection support to res.redirect()added req.ip for the remote address (supporting reverse proxies)added req.ips for remote address(es) (supporting reverse proxies)added [] support in jsonp callbackadded app.get(name) to compliment app.set(name, val)added app.engine() to register template engines (replaces app.register())added req.subdomains to return an array of subdomainsadded req.protocol to return the request protocol string (“http” or “https”)added req.secure to assert that req.protocol is “https”added req.path to return the parsed url’s pathnameadded req.host to return hostname (Host void of port)added debug() instrumentation to aid debuggingadded req.accepts()added req.acceptsLanguage()added req.acceptsCharset()added req.acceptedadded req.acceptedLanguagesadded req.acceptedCharsetsadded “json replacer” setting to manipulate json responses (remove private keys etc)added “json spaces” setting to compress or expand json as you like (defaults to 2 in dev)added express.application prototypeadded express.request prototypeadded express.response prototypeadded app.render() for app-level templatesadded res.type() to replace old res.contentType()added { signed: true } option to res.cookie()added async signature to res.render(), engines in consolidate.js work OOTBremoved partial()removed express-level layout support (engines provide similar)renamed “case sensitive routes” to “case sensitive routing”removed res.signedCookie()removed “root” settingremoved res.redirect('home') supportremoved req.notify()removed app.register()removed app.redirect()removed app.is()removed app.helpers()removed app.dynamicHelpers()Head over to the New Features in 3.x wiki page for a more comprehensive list of additions, or to 3.x migration to help you upgrade if you wish to do so.