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 bcf9f00 · Browse files · 3 files·+247 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+247 added−0 removed
- other:+247 added−0 removed
Provenance
- Commit
dfecbe5- Tree
976de32- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
bcf9f00
3 files changed+247 added−0 removed
modified:docs/guide.1+100 added
209 unmodified lines210 .fi211 .212 .IP "" 0213 .214+.SS "ServerRequest#header(key[, defaultValue])"215+Get the case\-insensitive request header \fIkey\fR, with optional \fIdefaultValue\fR:216+.217+.IP "" 4218+.219+.nf220+221+req\.header(\'Host\');222+req\.header(\'host\');223+req\.header(\'Accept\', \'*/*\');224+.225+.fi226+.227+.IP "" 0228+.229+.SS "ServerRequest#accepts(type)"230+Check if the \fIAccept\fR header is present, and includes the given \fItype\fR\.231+.232+.P233+When the \fIAccept\fR header is not present \fItrue\fR is returned\. Otherwise the given \fItype\fR is matched by an exact match, and then subtypes\. You may pass the subtype such as \"html\" which is then converted internally to \"text/html\" using the mime lookup table\.234+.235+.IP "" 4236+.237+.nf238+239+// Accept: text/html240+req\.accepts(\'html\');241+// => true242+243+// Accept: text/*; application/json244+req\.accepts(\'html\');245+req\.accepts(\'text/html\');246+req\.accepts(\'text/plain\');247+req\.accepts(\'application/json\');248+// => true249+250+req\.accepts(\'image/png\');251+req\.accepts(\'png\');252+// => false253+.254+.fi255+.256+.IP "" 0257+.258+.SS "ServerRequest#param(name)"259+Return the value of param \fIname\fR when present\.260+.261+.IP "\(bu" 4262+Checks route placeholders, ex: /user/:id263+.264+.IP "\(bu" 4265+Checks query string params, ex: ?id=12266+.267+.IP "\(bu" 4268+Checks urlencoded body params, ex: id=12269+.270+.IP "" 0271+.272+.P273+To utilize urlencoded request bodies, \fIreq\.body\fR should be an object\. This can be done by using the \fIconnect\.bodyDecoder\fR middleware\.274+.275+.SS "ServerRequest#flash(type[, msg])"276+Queue flash \fImsg\fR of the given \fItype\fR\.277+.278+.IP "" 4279+.280+.nf281+282+req\.flash(\'info\', \'email sent\');283+req\.flash(\'error\', \'email delivery failed\');284+req\.flash(\'info\', \'email re\-sent\');285+// => 2286+287+req\.flash(\'info\');288+// => [\'email sent\', \'email re\-sent\']289+290+req\.flash(\'info\');291+// => []292+293+req\.flash();294+// => { error: [\'email delivery failed\'], info: [] }295+.296+.fi297+.298+.IP "" 0299+.300+.SS "ServerRequest#isXMLHttpRequest"301+Also aliased as \fIreq\.xhr\fR, this getter checks the \fIX\-Requested\-With\fR header to see if it was issued by an \fIXMLHttpRequest\fR:302+.303+.IP "" 4304+.305+.nf306+307+req\.xhr308+req\.isXMLHttpRequest309+.310+.fi311+.312+.IP "" 0313+.314 .SS "ServerResponse#header(key[, val])"315 Get or set the response header \fIkey\fR\.316 .317 .IP "" 4178 unmodified linesmodified:docs/guide.html+77 added
312 unmodified lines313 connect.bodyDecoder()314 );315 </code></pre>316 317+<h3 id="ServerRequest-header-key-defaultValue-">ServerRequest#header(key[, defaultValue])</h3>318+319+<p>Get the case-insensitive request header <em>key</em>, with optional <em>defaultValue</em>:</p>320+321+<pre><code>req.header('Host');322+req.header('host');323+req.header('Accept', '*/*');324+</code></pre>325+326+<h3 id="ServerRequest-accepts-type-">ServerRequest#accepts(type)</h3>327+328+<p>Check if the <em>Accept</em> header is present, and includes the given <em>type</em>.</p>329+330+<p>When the <em>Accept</em> header is not present <em>true</em> is returned. Otherwise331+the given <em>type</em> is matched by an exact match, and then subtypes. You332+may pass the subtype such as "html" which is then converted internally333+to "text/html" using the mime lookup table.</p>334+335+<pre><code>// Accept: text/html336+req.accepts('html');337+// => true338+339+// Accept: text/*; application/json340+req.accepts('html');341+req.accepts('text/html');342+req.accepts('text/plain');343+req.accepts('application/json');344+// => true345+346+req.accepts('image/png');347+req.accepts('png');348+// => false349+</code></pre>350+351+<h3 id="ServerRequest-param-name-">ServerRequest#param(name)</h3>352+353+<p>Return the value of param <em>name</em> when present.</p>354+355+<ul>356+<li>Checks route placeholders, ex: /user/:id</li>357+<li>Checks query string params, ex: ?id=12</li>358+<li>Checks urlencoded body params, ex: id=12</li>359+</ul>360+361+362+<p>To utilize urlencoded request bodies, <em>req.body</em>363+should be an object. This can be done by using364+the <em>connect.bodyDecoder</em> middleware.</p>365+366+<h3 id="ServerRequest-flash-type-msg-">ServerRequest#flash(type[, msg])</h3>367+368+<p>Queue flash <em>msg</em> of the given <em>type</em>.</p>369+370+<pre><code>req.flash('info', 'email sent');371+req.flash('error', 'email delivery failed');372+req.flash('info', 'email re-sent');373+// => 2374+375+req.flash('info');376+// => ['email sent', 'email re-sent']377+378+req.flash('info');379+// => []380+381+req.flash();382+// => { error: ['email delivery failed'], info: [] }383+</code></pre>384+385+<h3 id="ServerRequest-isXMLHttpRequest">ServerRequest#isXMLHttpRequest</h3>386+387+<p>Also aliased as <em>req.xhr</em>, this getter checks the <em>X-Requested-With</em> header388+to see if it was issued by an <em>XMLHttpRequest</em>:</p>389+390+<pre><code>req.xhr391+req.isXMLHttpRequest392+</code></pre>393+394 <h3 id="ServerResponse-header-key-val-">ServerResponse#header(key[, val])</h3>395 396 <p>Get or set the response header <em>key</em>.</p>397 115 unmodified linesmodified:docs/guide.md+70 added
139 unmodified lines140 connect.logger(),141 connect.bodyDecoder()142 );143 144+### ServerRequest#header(key[, defaultValue])145+146+Get the case-insensitive request header _key_, with optional _defaultValue_:147+148+ req.header('Host');149+ req.header('host');150+ req.header('Accept', '*/*');151+152+### ServerRequest#accepts(type)153+154+Check if the _Accept_ header is present, and includes the given _type_.155+156+When the _Accept_ header is not present _true_ is returned. Otherwise157+the given _type_ is matched by an exact match, and then subtypes. You158+may pass the subtype such as "html" which is then converted internally159+to "text/html" using the mime lookup table.160+161+ // Accept: text/html162+ req.accepts('html');163+ // => true164+165+ // Accept: text/*; application/json166+ req.accepts('html');167+ req.accepts('text/html');168+ req.accepts('text/plain');169+ req.accepts('application/json');170+ // => true171+172+ req.accepts('image/png');173+ req.accepts('png');174+ // => false175+176+### ServerRequest#param(name)177+178+Return the value of param _name_ when present.179+180+ - Checks route placeholders, ex: /user/:id181+ - Checks query string params, ex: ?id=12182+ - Checks urlencoded body params, ex: id=12183+184+To utilize urlencoded request bodies, _req.body_185+should be an object. This can be done by using186+the _connect.bodyDecoder_ middleware.187+188+### ServerRequest#flash(type[, msg])189+190+Queue flash _msg_ of the given _type_.191+192+ req.flash('info', 'email sent');193+ req.flash('error', 'email delivery failed');194+ req.flash('info', 'email re-sent');195+ // => 2196+197+ req.flash('info');198+ // => ['email sent', 'email re-sent']199+200+ req.flash('info');201+ // => []202+203+ req.flash();204+ // => { error: ['email delivery failed'], info: [] }205+206+### ServerRequest#isXMLHttpRequest207+208+Also aliased as _req.xhr_, this getter checks the _X-Requested-With_ header209+to see if it was issued by an _XMLHttpRequest_:210+211+ req.xhr212+ req.isXMLHttpRequest213+214 ### ServerResponse#header(key[, val])215 216 Get or set the response header _key_.217 98 unmodified lines