docs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 7705042 · Browse files · 5 files·+158 added−5 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
5 files+158 added−5 removed
- other:+158 added−5 removed
Provenance
- Commit
c1a82bf- Tree
c00827b- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
7705042
5 files changed+158 added−5 removed
modified:docs/guide.1+2 added-2 removed
1065 unmodified lines1066 .1067 .P1068 The \fIreq\.session\fR object also has methods such as \fISession#touch()\fR, \fISession#destroy()\fR, \fISession#regenerate()\fR among others to maintain and manipulate sessions\. For more information view the Connect Session \fIhttp://senchalabs\.github\.com/connect/middleware\-session\.html\fR documentation\.1069 .1070-.SS "Migration Guide"1071-Express 1\.x developers may reference the Migration Guide \fImigrate\.html\fR to get up to speed on how to upgrade your application\.1070+.SS "2\.x Migration Guide"1071+Express 1\.x developers may reference the Migration Guide \fImigrate\.html\fR to get up to speed on how to upgrade your application to work with Express 2\.x, Connect 1\.x, and Node 0\.4\.x\.1072 .1073 .SS "req\.header(key[, defaultValue])"1074 Get the case\-insensitive request header \fIkey\fR, with optional \fIdefaultValue\fR:1075 .1011 unmodified linesmodified:docs/guide.html+5 added-3 removed
194 unmodified lines195 <li><a href="#View-Partials">View Partials</a></li>196 <li><a href="#View-Lookup">View Lookup</a></li>197 <li><a href="#Template-Engines">Template Engines</a></li>198 <li><a href="#Session-Support">Session Support</a></li>199-<li><a href="#Migration-Guide">Migration Guide</a></li>199+<li><a href="#" class="toggle">+</a> <a class="section-title" href="#">2</a><ul class="section" id="section-2">200+<li><a href="#2-x-Migration-Guide">x Migration Guide</a></li>201+</ul></li>202 <li><a href="#" class="toggle">+</a> <a class="section-title" href="#">Request</a><ul class="section" id="section-Request">203 <li><a href="#req-header-key-defaultValue-">header()</a></li>204 <li><a href="#req-accepts-type-">accepts()</a></li>205 <li><a href="#req-is-type-">is()</a></li>712 unmodified lines918 </code></pre>919 920 <p>The <em>req.session</em> object also has methods such as <em>Session#touch()</em>, <em>Session#destroy()</em>, <em>Session#regenerate()</em> among others to maintain and manipulate sessions. For more information view the <a href="http://senchalabs.github.com/connect/middleware-session.html">Connect Session</a> documentation.</p>921 920-<h3 id="Migration-Guide">Migration Guide</h3>922+<h3 id="2-x-Migration-Guide">2.x Migration Guide</h3>923 922-<p> Express 1.x developers may reference the <a href="migrate.html">Migration Guide</a> to get up to speed on how to upgrade your application.</p>924+<p> Express 1.x developers may reference the <a href="migrate.html">Migration Guide</a> to get up to speed on how to upgrade your application to work with Express 2.x, Connect 1.x, and Node 0.4.x.</p>925 926 <h3 id="req-header-key-defaultValue-">req.header(key[, defaultValue])</h3>927 928 <p>Get the case-insensitive request header <em>key</em>, with optional <em>defaultValue</em>:</p>640 unmodified linesmodified:docs/migrate.1+70 added
5 unmodified lines6 .SH "NAME"7 \fBmigrate\fR8 .9 .SS "Express 1\.x to 2\.x Migration"10+.11+.SS "HTTPS"12+Creating an HTTPS server is simply, simply pass the TLS options to \fIexpress\.createServer()\fR:13+.14+.IP "" 415+.16+.nf17 18+ var app = express\.createServer({19+ key: \.\.\.20+ , cert: \.\.\.21+ });22+23+ app\.listen(443);24+.25+.fi26+.27+.IP "" 028+.29+.SS "req\.header() Referrer"30+Previously if anyone was doing something similar to:31+.32+.IP "" 433+.34+.nf35+36+ req\.headers\.referrer || req\.headers\.referer37+ req\.header(\'Referrer\') || req\.header(\'Referer\')38+.39+.fi40+.41+.IP "" 042+.43+.P44+With the new special\-case we may now simply use \fIReferrer\fR which will return either if defined:45+.46+.IP "" 447+.48+.nf49+50+ req\.header(\'Referrer\')51+.52+.fi53+.54+.IP "" 055+.56+.SS "res\.local(name, val)"57+Previously all local variables had to be passed to \fIres\.render()\fR, or either \fIapp\.helpers()\fR or \fIapp\.dynamicHelpers()\fR, now we may do this at the request\-level progressively\. The \fIres\.local()\fR method accepts a \fIname\fR and \fIval\fR, however the locals passed to \fIres\.render()\fR will take precedence\.58+.59+.P60+For example we may utilize this feature to create locals in middleware:61+.62+.IP "" 463+.64+.nf65+66+ function loadUser(req, res, next) {67+ User\.get(req\.params\.id, function(err, user){68+ res\.local(\'user\', user);69+ next();70+ });71+ }72+73+ app\.get(\'/user/:id\', loadUser, function(req, res){74+ res\.render(\'user\');75+ });76+.77+.fi78+.79+.IP "" 080+modified:docs/migrate.html+43 added
195 unmodified lines196 <code>migrate</code>197 </p>198 <h3 id="Express-1-x-to-2-x-Migration">Express 1.x to 2.x Migration</h3>199 200+<h3 id="HTTPS">HTTPS</h3>201+202+<p> Creating an HTTPS server is simply, simply pass the TLS options to <em>express.createServer()</em>:</p>203+204+<pre><code> var app = express.createServer({205+ key: ...206+ , cert: ...207+ });208+209+ app.listen(443);210+</code></pre>211+212+<h3 id="req-header-Referrer">req.header() Referrer</h3>213+214+<p> Previously if anyone was doing something similar to:</p>215+216+<pre><code> req.headers.referrer || req.headers.referer217+ req.header('Referrer') || req.header('Referer')218+</code></pre>219+220+<p> With the new special-case we may now simply use <em>Referrer</em> which will return either if defined:</p>221+222+<pre><code> req.header('Referrer')223+</code></pre>224+225+<h3 id="res-local-name-val-">res.local(name, val)</h3>226+227+<p> Previously all local variables had to be passed to <em>res.render()</em>, or either <em>app.helpers()</em> or <em>app.dynamicHelpers()</em>, now we may do this at the request-level progressively. The <em>res.local()</em> method accepts a <em>name</em> and <em>val</em>, however the locals passed to <em>res.render()</em> will take precedence.</p>228+229+<p> For example we may utilize this feature to create locals in middleware:</p>230+231+<pre><code> function loadUser(req, res, next) {232+ User.get(req.params.id, function(err, user){233+ res.local('user', user);234+ next();235+ });236+ }237+238+ app.get('/user/:id', loadUser, function(req, res){239+ res.render('user');240+ });241+</code></pre>242+243 </div>244 </div>245 </div>246 </body>1 unmodified linemodified:docs/migrate.md+38 added
1234567891011121314151617181920212223242526272829303132333435363738394041
### Express 1.x to 2.x Migration
### HTTPS
Creating an HTTPS server is simply, simply pass the TLS options to _express.createServer()_: var app = express.createServer({ key: ... , cert: ... });
app.listen(443);
### req.header() Referrer
Previously if anyone was doing something similar to: req.headers.referrer || req.headers.referer req.header('Referrer') || req.header('Referer')
With the new special-case we may now simply use _Referrer_ which will return either if defined: req.header('Referrer')
### res.local(name, val)
Previously all local variables had to be passed to _res.render()_, or either _app.helpers()_ or _app.dynamicHelpers()_, now we may do this at the request-level progressively. The _res.local()_ method accepts a _name_ and _val_, however the locals passed to _res.render()_ will take precedence.
For example we may utilize this feature to create locals in middleware:
function loadUser(req, res, next) { User.get(req.params.id, function(err, user){ res.local('user', user); next(); }); }
app.get('/user/:id', loadUser, function(req, res){ res.render('user'); });No newline at end of file