Skip to content
Myr

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

5 files+158 added−5 removed

modified:docs/guide.1+2 added-2 removed
1065 unmodified lines
1066.1067.P1068The \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"1071Express 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"1071Express 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])"1074Get the case\-insensitive request header \fIkey\fR, with optional \fIdefaultValue\fR:1075.
1011 unmodified lines
modified:docs/guide.html+5 added-3 removed
194 unmodified lines
195<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 lines
918</code></pre>919920<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>921920<h3 id="Migration-Guide">Migration Guide</h3>922<h3 id="2-x-Migration-Guide">2.x Migration Guide</h3>923922<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>925926<h3 id="req-header-key-defaultValue-">req.header(key[, defaultValue])</h3>927928<p>Get the case-insensitive request header <em>key</em>, with optional <em>defaultValue</em>:</p>
640 unmodified lines
modified:docs/migrate.1+70 added
5 unmodified lines
6.SH "NAME"7\fBmigrate\fR8.9.SS "Express 1\.x to 2\.x Migration"10.11.SS "HTTPS"12Creating an HTTPS server is simply, simply pass the TLS options to \fIexpress\.createServer()\fR:13.14.IP "" 415.16.nf1718 var app = express\.createServer({19 key: \.\.\.20 , cert: \.\.\.21 });2223 app\.listen(443);24.25.fi26.27.IP "" 028.29.SS "req\.header() Referrer"30Previously if anyone was doing something similar to:31.32.IP "" 433.34.nf3536 req\.headers\.referrer || req\.headers\.referer37 req\.header(\'Referrer\') || req\.header(\'Referer\')38.39.fi40.41.IP "" 042.43.P44With the new special\-case we may now simply use \fIReferrer\fR which will return either if defined:45.46.IP "" 447.48.nf4950 req\.header(\'Referrer\')51.52.fi53.54.IP "" 055.56.SS "res\.local(name, val)"57Previously 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.P60For example we may utilize this feature to create locals in middleware:61.62.IP "" 463.64.nf6566 function loadUser(req, res, next) {67 User\.get(req\.params\.id, function(err, user){68 res\.local(\'user\', user);69 next();70 });71 }7273 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 lines
196 <code>migrate</code>197</p>198<h3 id="Express-1-x-to-2-x-Migration">Express 1.x to 2.x Migration</h3>199200<h3 id="HTTPS">HTTPS</h3>201202<p> Creating an HTTPS server is simply, simply pass the TLS options to <em>express.createServer()</em>:</p>203204<pre><code> var app = express.createServer({205 key: ...206 , cert: ...207 });208209 app.listen(443);210</code></pre>211212<h3 id="req-header-Referrer">req.header() Referrer</h3>213214<p> Previously if anyone was doing something similar to:</p>215216<pre><code> req.headers.referrer || req.headers.referer217 req.header('Referrer') || req.header('Referer')218</code></pre>219220<p> With the new special-case we may now simply use <em>Referrer</em> which will return either if defined:</p>221222<pre><code> req.header('Referrer')223</code></pre>224225<h3 id="res-local-name-val-">res.local(name, val)</h3>226227<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>228229<p> For example we may utilize this feature to create locals in middleware:</p>230231<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 }237238 app.get('/user/:id', loadUser, function(req, res){239 res.render('user');240 });241</code></pre>242243</div>244 </div>245 </div>246 </body>
1 unmodified line
modified:docs/migrate.md+38 added