Skip to content

Commit

Permalink
docs
Browse files Browse the repository at this point in the history
  • Loading branch information
tj committed Aug 6, 2011
1 parent 75361fb commit a370039
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
42 changes: 37 additions & 5 deletions docs/guide.html
Expand Up @@ -180,8 +180,6 @@
</a>
<div id="wrapper">
<div id="container"><ul id="toc">

</ul><ul id="toc">
<li><a href="#installation">Installation</a></li>
<li><a href="#creating-a server">Creating A Server</a></li>
<li><a href="#creating-an https server">Creating An HTTPS Server</a></li>
Expand Down Expand Up @@ -217,6 +215,7 @@
<li><a href="#res.sendfile()">sendfile()</a></li>
<li><a href="#res.download()">download()</a></li>
<li><a href="#res.send()">send()</a></li>
<li><a href="#res.json()">json()</a></li>
<li><a href="#res.redirect()">redirect()</a></li>
<li><a href="#res.cookie()">cookie()</a></li>
<li><a href="#res.clearcookie()">clearCookie()</a></li>
Expand Down Expand Up @@ -335,6 +334,13 @@ <h3 id="configuration">Configuration</h3>
});
</code></pre>

<p>For similar environments you may also pass several env strings:</p>

<pre><code>app.configure('stage', 'prod', function(){
// config
});
</code></pre>

<p>For internal and arbitrary settings Express provides the <em>set(key[, val])</em>, <em>enable(key)</em>, <em>disable(key)</em> methods:</p>

<pre><code> app.configure(function(){
Expand Down Expand Up @@ -371,6 +377,8 @@ <h3 id="settings">Settings</h3>
<li><em>view options</em> An object specifying global view options</li>
<li><em>view cache</em> Enable view caching (enabled in production)</li>
<li><em>case sensitive routes</em> Enable case-sensitive routing</li>
<li><em>strict routing</em> When enabled trailing slashes are no longer ignored</li>
<li><em>jsonp callback</em> Enable <em>res.send()</em> / <em>res.json()</em> transparent jsonp support</li>
</ul>


Expand Down Expand Up @@ -1268,6 +1276,19 @@ <h3 id="res.send()">res.send(body|status[, headers|status[, status]])</h3>

<p>Note that this method <em>end()</em>s the response, so you will want to use node&rsquo;s <em>res.write()</em> for multiple writes or streaming.</p>

<h3 id="res.json()">res.json(obj[, headers|status[, status]])</h3>

<p> Send a JSON response with optional <em>headers</em> and <em>status</em>. This method
is ideal for JSON-only APIs, however <em>res.send(obj)</em> will send JSON as
well, though not ideal for cases when you want to send for example a string
as JSON, since the default for <em>res.send(string)</em> is text/html.</p>

<pre><code>res.json(null);
res.json({ user: 'tj' });
res.json('oh noes!', 500);
res.json('I dont have that', 404);
</code></pre>

<h3 id="res.redirect()">res.redirect(url[, status])</h3>

<p>Redirect to the given <em>url</em> with a default response <em>status</em> of 302.</p>
Expand All @@ -1285,7 +1306,8 @@ <h3 id="res.redirect()">res.redirect(url[, status])</h3>

<h3 id="res.cookie()">res.cookie(name, val[, options])</h3>

<p>Sets the given cookie <em>name</em> to <em>val</em>, with options <em>httpOnly</em>, <em>secure</em>, <em>expires</em> etc.</p>
<p>Sets the given cookie <em>name</em> to <em>val</em>, with options <em>httpOnly</em>, <em>secure</em>, <em>expires</em> etc. The <em>path</em> option defaults to the app&rsquo;s &ldquo;home&rdquo; setting, which
is typically &ldquo;/&rdquo;.</p>

<pre><code>// "Remember me" for 15 minutes
res.cookie('rememberme', 'yes', { expires: new Date(Date.now() + 900000), httpOnly: true });
Expand All @@ -1307,7 +1329,8 @@ <h3 id="res.cookie()">res.cookie(name, val[, options])</h3>

<h3 id="res.clearcookie()">res.clearCookie(name[, options])</h3>

<p>Clear cookie <em>name</em> by setting &ldquo;expires&rdquo; far in the past.</p>
<p>Clear cookie <em>name</em> by setting &ldquo;expires&rdquo; far in the past. Much like
<em>res.cookie()</em> the <em>path</em> option also defaults to the &ldquo;home&rdquo; setting.</p>

<pre><code>res.clearCookie('rememberme');
</code></pre>
Expand All @@ -1324,6 +1347,16 @@ <h3 id="res.render()">res.render(view[, options[, fn]])</h3>
res.render('index', { layout: false, user: user });
</code></pre>

<p>This <em>options</em> object is also considered an &ldquo;options&rdquo; object. For example
when you pass the <em>status</em> local, it&rsquo;s not only available to the view, it
sets the response status to this number. This is also useful if a template
engine accepts specific options, such as <em>debug</em>, or <em>compress</em>. Below
is an example of how one might render an error page, passing the <em>status</em> for
display, as well as it setting <em>res.statusCode</em>.</p>

<pre><code> res.render('error', { status: 500, message: 'Internal Server Error' });
</code></pre>

<h3 id="res.partial()">res.partial(view[, options])</h3>

<p>Render <em>view</em> partial with the given <em>options</em>. This method is always available
Expand Down Expand Up @@ -1596,7 +1629,6 @@ <h3 id="app.helpers()">app.helpers(obj)</h3>
<p>Express also provides a few locals by default:</p>

<pre><code>- `settings` the app's settings object
- `filename` the view's filename
- `layout(path)` specify the layout from within a view
</code></pre>

Expand Down
4 changes: 0 additions & 4 deletions docs/index.html
Expand Up @@ -254,10 +254,6 @@ <h2>More Information</h2>
<li><a href="http://groups.google.com/group/express-js">Google Group</a> for discussion</li>
<li>Visit the <a href="http://github.com/visionmedia/express/wiki">Wiki</a></li>
<li><a href="http://hideyukisaito.com/doc/expressjs/">日本語ドキュメンテーション</a> by <a href="https://github.com/hideyukisaito">hideyukisaito</a></li>
<li>Screencast &ndash; <a href="http://bit.ly/eRYu0O">Introduction</a></li>
<li>Screencast &ndash; <a href="http://bit.ly/dU13Fx">View Partials</a></li>
<li>Screencast &ndash; <a href="http://bit.ly/hX4IaH">Route Specific Middleware</a></li>
<li>Screencast &ndash; <a href="http://bit.ly/eNqmVs">Route Path Placeholder Preconditions</a></li>
</ul>

</div>
Expand Down

0 comments on commit a370039

Please sign in to comment.