More 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 76052b4 · Browse files · 4 files·+143 added−60 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+143 added−60 removed
- other:+143 added−60 removed
Provenance
- Commit
0c5fe61- Tree
961ddc5- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
76052b4
4 files changed+143 added−60 removed
modified:docs/api.html+64 added-60 removed
316 unmodified lines317 <li><p><strong>param</strong>: <em>String</em> name</p></li>318 <li><p><strong>return</strong>: <em>String</em></p></li>319 <li><p><strong>api</strong>: <em>public</em></p></li>320 </ul>321-321+���:322 </td>323 <td class="code">324 <pre><code><span class="variable">http</span>.<span class="class">IncomingMessage</span>.<span class="variable">prototype</span>.<span class="variable">param</span> = <span class="keyword">function</span>(<span class="variable">name</span>){325 <span class="comment">// Route params like /user/:id</span>143 unmodified lines469 <span class="this">this</span>.<span class="variable">contentType</span>(<span class="string">'.html'</span>);470 }471 <span class="keyword">break</span>;472 <span class="keyword">case</span> <span class="string">'object'</span>:473- <span class="keyword">if</span> (!(<span class="variable">body</span> <span class="variable">instanceof</span> <span class="class">Buffer</span>)) {473+ <span class="keyword">if</span> (<span class="variable">body</span> <span class="variable">instanceof</span> <span class="class">Buffer</span>) {474 <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Type'</span>]) {475+ <span class="this">this</span>.<span class="variable">contentType</span>(<span class="string">'.bin'</span>);476+ }477+ } <span class="keyword">else</span> {478+ <span class="keyword">if</span> (!<span class="this">this</span>.<span class="variable">headers</span>[<span class="string">'Content-Type'</span>]) {479 <span class="this">this</span>.<span class="variable">contentType</span>(<span class="string">'.json'</span>);480 }481 <span class="variable">body</span> = <span class="class">JSON</span>.<span class="variable">stringify</span>(<span class="variable">body</span>);482 }159 unmodified lines642 <span class="this">this</span>.<span class="variable">end</span>();643 };644 </code></pre>645 </td>642-</tr><tr class="filename"><td><h2 id="lib/express/utils.js">utils</h2></td><td>lib/express/utils.js</td></tr><tr class="code">643-<td class="docs">644-<p>Parse mini markdown implementation.645-The following conversions are supported,646-primarily for the “flash” middleware:</p>647-648-<p> <em>foo</em> or <em>foo</em> become <em>foo</em>649- <strong>foo</strong> or <strong>foo</strong> become <strong>foo</strong>650- <a href="B">A</a> becomes <a href="B">A</a></p>651-652-<h2></h2>653-654-<ul>655-<li><p><strong>param</strong>: <em>String</em> str</p></li>656-<li><p><strong>return</strong>: <em>String</em></p></li>657-<li><p><strong>api</strong>: <em>public</em></p></li>658-</ul>659- 660-</td>661-<td class="code">662-<pre><code><span class="variable">exports</span>.<span class="variable">miniMarkdown</span> = <span class="keyword">function</span>(<span class="variable">str</span>){663- <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">str</span>)664- .<span class="variable">replace</span>(<span class="regexp">/(__|\*\*)(.*?)\1/g</span>, <span class="string">'<strong>$2</strong>'</span>)665- .<span class="variable">replace</span>(<span class="regexp">/(_|\*)(.*?)\1/g</span>, <span class="string">'<em>$2</em>'</span>)666- .<span class="variable">replace</span>(<span class="regexp">/\[([^\]]+)\]\(([^)]+)\)/g</span>, <span class="string">'<a href="$2">$1</a>'</span>);667-};</code></pre>668-</td>669-</tr>670-<tr class="code">671-<td class="docs">672-<p>Escape special characters in the given string of html.</p>673-674-<h2></h2>675-676-<ul>677-<li><p><strong>param</strong>: <em>String</em> html</p></li>678-<li><p><strong>return</strong>: <em>String</em></p></li>679-<li><p><strong>api</strong>: <em>public</em></p></li>680-</ul>681-682-</td>683-<td class="code">684-<pre><code><span class="variable">exports</span>.<span class="variable">htmlEscape</span> = <span class="keyword">function</span>(<span class="variable">html</span>) {685- <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">html</span>)686- .<span class="variable">replace</span>(<span class="regexp">/&/g</span>, <span class="string">'&'</span>)687- .<span class="variable">replace</span>(<span class="regexp">/"/g</span>, <span class="string">'"'</span>)688- .<span class="variable">replace</span>(<span class="regexp">/</g</span>, <span class="string">'<'</span>)689- .<span class="variable">replace</span>(<span class="regexp">/>/g</span>, <span class="string">'>'</span>);690-};</code></pre>691-</td>646 </tr><tr class="filename"><td><h2 id="lib/express/server.js">server</h2></td><td>lib/express/server.js</td></tr><tr class="code">647 <td class="docs">648 <p>Module dependencies.</p>649 </td>51 unmodified lines701 </td>702 </tr>703 <tr class="code">704 <td class="docs">751-<p>Inherit from <code>connect.Server</code>.</p>�
`705+<p>Inherit from <code>connect.Server</code>.</p>N %706 </td>707 <td class="code">708 <pre><code><span class="variable">sys</span>.<span class="variable">inherits</span>(<span class="class">Server</span>, <span class="variable">connect</span>.<span class="class">Server</span>);</code></pre>709 </td>39 unmodified lines749 <li><p><strong>param</strong>: <em>String</em> env …</p></li>750 <li><p><strong>return</strong>: <em>Server</em> for chaining</p></li>751 <li><p><strong>api</strong>: <em>public</em></p></li>752 </ul>753+;</p>754 755+<h2><756 </td>757 <td class="code">758 <pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">runConfig</span> = <span class="keyword">function</span>(){759 <span class="keyword">for</span> (<span class="keyword">var</span> <span class="variable">i</span> = <span class="number integer">0</span>, <span class="variable">len</span> = <span class="variable">arguments</span>.<span class="variable">length</span>; <span class="variable">i</span> &<span class="variable">lt</span>; <span class="variable">len</span>; ++<span class="variable">i</span>) {123 unmodified lines883 <li><p><strong>param</strong>: <em>String</em> setting</p></li>884 <li><p><strong>return</strong>: <em>Server</em> for chaining</p></li>885 <li><p><strong>api</strong>: <em>public</em></p></li>886 </ul>931-Q887+888 </td>889 <td class="code">890 <pre><code><span class="class">Server</span>.<span class="variable">prototype</span>.<span class="variable">configure</span> = <span class="keyword">function</span>(<span class="variable">env</span>, <span class="variable">fn</span>){891 <span class="keyword">if</span> (<span class="keyword">typeof</span> <span class="variable">env</span> === <span class="string">'function'</span>) <span class="variable">fn</span> = <span class="variable">env</span>, <span class="variable">env</span> = <span class="string">'any'</span>;11 unmodified lines903 <span class="keyword">return</span> <span class="variable">arguments</span>.<span class="variable">callee</span>;904 })(<span class="string">'get'</span>)(<span class="string">'post'</span>)(<span class="string">'put'</span>)(<span class="string">'del'</span>);905 </code></pre>906 </td>907+</tr><tr class="filename"><td><h2 id="lib/express/utils.js">utils</h2></td><td>lib/express/utils.js</td></tr><tr class="code">908+<td class="docs">909+<p>Parse mini markdown implementation.910+The following conversions are supported,911+primarily for the “flash” middleware:</p>912+913+<p> <em>foo</em> or <em>foo</em> become <em>foo</em>914+ <strong>foo</strong> or <strong>foo</strong> become <strong>foo</strong>915+ <a href="B">A</a> becomes <a href="B">A</a></p>916+917+<h2></h2>918+919+<ul>920+<li><p><strong>param</strong>: <em>String</em> str</p></li>921+<li><p><strong>return</strong>: <em>String</em></p></li>922+<li><p><strong>api</strong>: <em>public</em></p></li>923+</ul>924+925+</td>926+<td class="code">927+<pre><code><span class="variable">exports</span>.<span class="variable">miniMarkdown</span> = <span class="keyword">function</span>(<span class="variable">str</span>){928+ <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">str</span>)929+ .<span class="variable">replace</span>(<span class="regexp">/(__|\*\*)(.*?)\1/g</span>, <span class="string">'<strong>$2</strong>'</span>)930+ .<span class="variable">replace</span>(<span class="regexp">/(_|\*)(.*?)\1/g</span>, <span class="string">'<em>$2</em>'</span>)931+ .<span class="variable">replace</span>(<span class="regexp">/\[([^\]]+)\]\(([^)]+)\)/g</span>, <span class="string">'<a href="$2">$1</a>'</span>);932+};</code></pre>933+</td>934+</tr>935+<tr class="code">936+<td class="docs">937+<p>Escape special characters in the given string of html.</p>938+939+<h2></h2>940+941+<ul>942+<li><p><strong>param</strong>: <em>String</em> html</p></li>943+<li><p><strong>return</strong>: <em>String</em></p></li>944+<li><p><strong>api</strong>: <em>public</em></p></li>945+</ul>946+947+</td>948+<td class="code">949+<pre><code><span class="variable">exports</span>.<span class="variable">htmlEscape</span> = <span class="keyword">function</span>(<span class="variable">html</span>) {950+ <span class="keyword">return</span> <span class="class">String</span>(<span class="variable">html</span>)951+ .<span class="variable">replace</span>(<span class="regexp">/&/g</span>, <span class="string">'&'</span>)952+ .<span class="variable">replace</span>(<span class="regexp">/"/g</span>, <span class="string">'"'</span>)953+ .<span class="variable">replace</span>(<span class="regexp">/</g</span>, <span class="string">'<'</span>)954+ .<span class="variable">replace</span>(<span class="regexp">/>/g</span>, <span class="string">'>'</span>);955+};</code></pre>956+</td>957 </tr><tr class="filename"><td><h2 id="lib/express/view.js">view</h2></td><td>lib/express/view.js</td></tr><tr class="code">958 <td class="docs">959 <p>Module dependencies.</p>960 </td>40 unmodified lines1001 1002 <ul>1003 <li><strong>api</strong>: <em>public</em></li>1004 </ul>999-r1000-of cal 1005+] %1006 </td>1007 <td class="code">1008 <pre><code><span class="variable">exports</span>.<span class="variable">clearCache</span> = <span class="keyword">function</span>(){1009 <span class="variable">viewCache</span> = {};6 unmodified lines1016 1017 <ul>1018 <li><strong>type</strong>: <em>Object</em></li>1019 </ul>1015-P1020+1021 </td>1022 <td class="code">1023 <pre><code><span class="keyword">var</span> <span class="variable">helpers</span> = <span class="variable">exports</span>.<span class="variable">helpers</span> = {};</code></pre>1024 </td>25 unmodified lines1050 <li><p><strong>param</strong>: <em>Object | Array</em> options or collection</p></li>1051 <li><p><strong>return</strong>: <em>String</em></p></li>1052 <li><p><strong>api</strong>: <em>public</em></p></li>1053 </ul>1049-P1054+ %1055 </td>1056 <td class="code">1057 <pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">partial</span> = <span class="keyword">function</span>(<span class="variable">view</span>, <span class="variable">options</span>, <span class="variable">ext</span>){1058 <span class="keyword">if</span> (<span class="variable">ext</span> &<span class="variable">amp</span>;&<span class="variable">amp</span>; <span class="variable">view</span>.<span class="variable">indexOf</span>(<span class="string">'.'</span>) &<span class="variable">lt</span>; <span class="number integer">0</span>) {57 unmodified lines1116 <li><p><strong>param</strong>: <em>Object</em> options</p></li>1117 <li><p><strong>param</strong>: <em>Function</em> fn</p></li>1118 <li><p><strong>api</strong>: <em>public</em></p></li>1119 </ul>1115-(.*?)\/[a-z]*)/1116-})1120+1121 </td>1122 <td class="code">1123 <pre><code><span class="variable">http</span>.<span class="class">ServerResponse</span>.<span class="variable">prototype</span>.<span class="variable">render</span> = <span class="keyword">function</span>(<span class="variable">view</span>, <span class="variable">options</span>, <span class="variable">fn</span>){1124 <span class="variable">options</span> = <span class="variable">options</span> || {};93 unmodified linesmodified:docs/guide.1+35 added
209 unmodified lines210 .fi211 .212 .IP "" 0213 .214+.SS "ServerResponse#header(key[, val])"215+Get or set the response header \fIkey\fR\.216+.217+.IP "" 4218+.219+.nf220+221+res\.header(\'Content\-Length\');222+// => undefined223+224+res\.header(\'Content\-Length\', 123);225+// => 123226+227+res\.header(\'Content\-Length\');228+// => 123229+.230+.fi231+.232+.IP "" 0233+.234+.SS "ServerResponse#contentType(type)"235+Sets the \fIContent\-Type\fR response header to the given \fItype\fR\.236+.237+.IP "" 4238+.239+.nf240+241+ var filename = \'path/to/image\.png\';242+ res\.contentType(filename);243+ // res\.headers[\'Content\-Type\'] is now \"image/png\"244+.245+.fi246+.247+.IP "" 0248+.249 .SS "ServerRequest#send(body|status[, headers|status[, status]])"250 The \fBres\.send()\fR method is a high level response utility allowing you to pass objects to respond with json, strings for html, arbitrary _Buffer_s or numbers for status code based responses\. The following are all valid uses:251 .252 .IP "" 486 unmodified linesmodified:docs/guide.html+23 added
312 unmodified lines313 connect.bodyDecoder()314 );315 </code></pre>316 317+<h3 id="ServerResponse-header-key-val-">ServerResponse#header(key[, val])</h3>318+319+<p>Get or set the response header <em>key</em>.</p>320+321+<pre><code>res.header('Content-Length');322+// => undefined323+324+res.header('Content-Length', 123);325+// => 123326+327+res.header('Content-Length');328+// => 123329+</code></pre>330+331+<h3 id="ServerResponse-contentType-type-">ServerResponse#contentType(type)</h3>332+333+<p>Sets the <em>Content-Type</em> response header to the given <em>type</em>.</p>334+335+<pre><code> var filename = 'path/to/image.png';336+ res.contentType(filename);337+ // res.headers['Content-Type'] is now "image/png"338+</code></pre>339+340 <h3 id="ServerRequest-send-body-status-headers-status-status-">ServerRequest#send(body|status[, headers|status[, status]])</h3>341 342 <p>The <code>res.send()</code> method is a high level response utility allowing you to pass343 objects to respond with json, strings for html, arbitrary _Buffer_s or numbers for status61 unmodified linesmodified:docs/guide.md+21 added
139 unmodified lines140 connect.logger(),141 connect.bodyDecoder()142 );143 144+### ServerResponse#header(key[, val])145+146+Get or set the response header _key_.147+148+ res.header('Content-Length');149+ // => undefined150+151+ res.header('Content-Length', 123);152+ // => 123153+154+ res.header('Content-Length');155+ // => 123156+157+### ServerResponse#contentType(type)158+159+Sets the _Content-Type_ response header to the given _type_.160+161+ var filename = 'path/to/image.png';162+ res.contentType(filename);163+ // res.headers['Content-Type'] is now "image/png"164+165 ### ServerRequest#send(body|status[, headers|status[, status]])166 167 The `res.send()` method is a high level response utility allowing you to pass168 objects to respond with json, strings for html, arbitrary _Buffer_s or numbers for status50 unmodified lines