Skip to content

Commit

Permalink
docs updated
Browse files Browse the repository at this point in the history
  • Loading branch information
RIAEvangelist committed Aug 11, 2017
1 parent 695a34a commit 764c65e
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 22 deletions.
57 changes: 57 additions & 0 deletions docs/README.md.html
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,63 @@ <h2 id="server-class">Server Class</h2>
</tr>
</tbody>
</table>
<h2 id="request-uri-query-and-body">request uri, query, and, body</h2>
<p>For handling api requests, posts, puts patches etc with body data, we are now making that available on the request as both a <code>String</code> and <code>Buffer</code> incase you need images or videos uploaded.</p>
<table>
<thead>
<tr>
<th>key</th>
<th>type</th>
<th>value</th>
</tr>
</thead>
<tbody>
<tr>
<td>request.body</td>
<td>string</td>
<td>request body</td>
</tr>
<tr>
<td>request.url</td>
<td>string</td>
<td>processed uri</td>
</tr>
<tr>
<td>request.uri</td>
<td>object</td>
<td>parsed url information and query</td>
</tr>
<tr>
<td>request.serverRoot</td>
<td>string</td>
<td>local dir for publicly served data</td>
</tr>
</tbody>
</table>
<table>
<thead>
<tr>
<th>key</th>
<th>type</th>
<th>value</th>
</tr>
</thead>
<tbody>
<tr>
<td>uri.protocol</td>
<td>string</td>
<td>protocol of request</td>
</tr>
<tr>
<td>uri.host</td>
<td>string</td>
<td>hostname for domain</td>
</tr>
</tbody>
</table>
<p>uri.hostname |string| hostname for domain|
|uri.query |object| parsed querystring|
|uri.port |number| port request was received on|</p>
<h3 id="-server-methods-http-riaevangelist-github-io-node-http-server-server-server-js-html-"><a href="http://riaevangelist.github.io/node-http-server/server/Server.js.html">Server Methods</a></h3>
<h4 id="deploy">deploy</h4>
<p><code>server.deploy</code> starts the server.</p>
Expand Down
68 changes: 46 additions & 22 deletions docs/server/Server.js.html
Original file line number Diff line number Diff line change
Expand Up @@ -973,7 +973,31 @@ <h4 id="afterserve">afterServe</h4>
}

request.url=uri;
request.serverRoot=root;</pre></div>
request.serverRoot=root;

request.body=<span class="hljs-string">''</span>;

request.on(
<span class="hljs-string">'data'</span>,
<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params">chunk</span>)</span>{
request.body+=chunk;
}.bind(<span class="hljs-keyword">this</span>)
).on(
<span class="hljs-string">'end'</span>,
<span class="hljs-function"><span class="hljs-keyword">function</span>(<span class="hljs-params"></span>)</span>{
<span class="hljs-keyword">if</span>(<span class="hljs-keyword">this</span>.config.verbose){
<span class="hljs-built_in">console</span>.log(<span class="hljs-string">`###REQUEST BODY :
<span class="hljs-subst">${request.body}</span>
###
`</span>);
}

requestBodyComplete.bind(<span class="hljs-keyword">this</span>,request,response)();
}.bind(<span class="hljs-keyword">this</span>)
);
}

<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">requestBodyComplete</span>(<span class="hljs-params">request,response</span>)</span>{</pre></div>
</div>
</li>

Expand All @@ -983,27 +1007,27 @@ <h4 id="afterserve">afterServe</h4>
<p>return any value to force or specify delayed or manual serving</p>

</div><div class="content">
<div class="highlight"><pre> <span class="hljs-keyword">if</span>(
<span class="hljs-keyword">this</span>.onRequest(
request,
response,
completeServing.bind(<span class="hljs-keyword">this</span>)
)
){
<span class="hljs-keyword">return</span>;
};

<span class="hljs-keyword">const</span> filename = path.join(
request.serverRoot,
request.url
);

fs.exists(
filename,
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fileExists</span>(<span class="hljs-params">exists</span>)</span>{
<span class="hljs-keyword">this</span>.serveFile(filename,exists,request,response);
}.bind(<span class="hljs-keyword">this</span>)
);
<div class="highlight"><pre> <span class="hljs-keyword">if</span>(
<span class="hljs-keyword">this</span>.onRequest(
request,
response,
completeServing.bind(<span class="hljs-keyword">this</span>)
)
){
<span class="hljs-keyword">return</span>;
};

<span class="hljs-keyword">const</span> filename = path.join(
request.serverRoot,
request.url
);

fs.exists(
filename,
<span class="hljs-function"><span class="hljs-keyword">function</span> <span class="hljs-title">fileExists</span>(<span class="hljs-params">exists</span>)</span>{
<span class="hljs-keyword">this</span>.serveFile(filename,exists,request,response);
}.bind(<span class="hljs-keyword">this</span>)
);
}

<span class="hljs-built_in">module</span>.exports=<span class="hljs-keyword">new</span> Server;</pre></div>
Expand Down

0 comments on commit 764c65e

Please sign in to comment.