mirror of
https://github.com/node-red/node-red.git
synced 2025-03-01 10:36:34 +00:00
More core node info help tidy up
This commit is contained in:
@@ -46,32 +46,43 @@
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="http in">
|
||||
<p>Provides an input node for http requests, allowing the creation of simple web services.</p>
|
||||
<p>The resulting message has the following properties:
|
||||
<ul>
|
||||
<li>msg.req : <a href="http://expressjs.com/api.html#req">http request</a></li>
|
||||
<li>msg.res : <a href="http://expressjs.com/api.html#res">http response</a></li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>For POST/PUT requests, the body is available under <code>msg.req.body</code>. This
|
||||
uses the <a href="http://expressjs.com/api.html#bodyParser">Express bodyParser middleware</a> to parse the content to a JSON object.
|
||||
</p>
|
||||
<p>
|
||||
By default, this expects the body of the request to be url encoded:
|
||||
<pre>foo=bar&this=that</pre>
|
||||
</p>
|
||||
<p>
|
||||
To send JSON encoded data to the node, the content-type header of the request must be set to
|
||||
<code>application/json</code>.
|
||||
</p>
|
||||
<p>
|
||||
If file uploads are enabled for POST requests, the files will be available under
|
||||
<code>msg.req.files</code>.
|
||||
<p>
|
||||
<b>Note: </b>This node does not send any response to the http request.
|
||||
This should be done with a subsequent HTTP Response node.
|
||||
</p>
|
||||
|
||||
<p>Creates an HTTP end-point for creating web services.</p>
|
||||
<h3>Outputs</h3>
|
||||
<dl class="message-properties">
|
||||
<dt>payload</dt>
|
||||
<dd>For a GET request, contains an object of any query string parameters.
|
||||
Otherwise, contains the body of the HTTP request.</dd>
|
||||
<dt>req<span class="property-type">object</span></dt>
|
||||
<dd>An HTTP request object. This object contains multiple properties that
|
||||
provide information about the request.
|
||||
<ul>
|
||||
<li><code>body</code> - the body of the incoming request. The format
|
||||
will depend on the request.</li>
|
||||
<li><code>headers</code> - an object containing the HTTP request headers.</li>
|
||||
<li><code>query</code> - an object containing any query string parameters.</li>
|
||||
<li><code>params</code> - an object containing any route parameters.</li>
|
||||
<li><code>cookies</code> - an object containing the cookies for the request.</li>
|
||||
<li><code>files</code> - if enabled with the node, an object containing
|
||||
any files uploaded as part of a POST request.</li>
|
||||
</ul>
|
||||
</dd>
|
||||
<dt>res<span class="property-type">object</span></dt>
|
||||
<dd>An HTTP response object. This property should not be used directly;
|
||||
the <code>HTTP Response</code> node documents how to respond to a request.
|
||||
This property must remain attached to the message passed to the response node.</dd>
|
||||
</dl>
|
||||
<h3>Details</h3>
|
||||
<p>The node will listen on the configured path for requests of a particular type.
|
||||
The path can be fully specified, such as <code>/user</code>, or include
|
||||
named parameters that accept any value, such as <code>/user/:name</code>.
|
||||
When named parameters are used, their actual value in a request can be accessed under `msg.req.params`.</p>
|
||||
<p>For requests that include a body, such as a POST or PUT, the contents of
|
||||
the request is made available as <code>msg.payload</code>.</p>
|
||||
<p>If the content type of the request can be determined, the body will be parsed to
|
||||
any appropriate type. For example, <code>application/json</code> will be parsed to
|
||||
its JavaScript object representation.</p>
|
||||
<p><b>Note:</b> this node does not send any response to the request. The flow
|
||||
must include an HTTP Response node to complete the request.</p>
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-template-name="http response">
|
||||
@@ -93,19 +104,24 @@
|
||||
</script>
|
||||
|
||||
<script type="text/x-red" data-help-name="http response">
|
||||
<p>Sends responses back to http requests received from an HTTP Input node.</p>
|
||||
<p>The response can be customised using the following message properties:</p>
|
||||
<ul>
|
||||
<li><code>payload</code> is sent as the body of the response</li>
|
||||
<li><code>statusCode</code>, if set, is used as the response status code (default: 200)</li>
|
||||
<li><code>headers</code>, if set, should be an object containing field/value
|
||||
pairs to be added as response headers.</li>
|
||||
<li><code>cookies</code>, if set, can be used to set or delete cookies.
|
||||
</ul>
|
||||
<p>Sends responses back to requests received from an HTTP Input node.</p>
|
||||
|
||||
<h3>Inputs</h3>
|
||||
<dl class="message-properties">
|
||||
<dt>payload <span class="property-type">string</span></dt>
|
||||
<dd>The body of the response.</dd>
|
||||
<dt class="optional">statusCode <span class="property-type">number</span></dt>
|
||||
<dd>If set, this is used as the response status code. Default: 200.</dd>
|
||||
<dt class="optional">headers <span class="property-type">object</span></dt>
|
||||
<dd>If set, provides HTTP headers to include in the response.</dd>
|
||||
<dt class="optional">cookies <span class="property-type">object</span></dt>
|
||||
<dd>If set, can be used to set or delete cookies.</dd>
|
||||
</dl>
|
||||
<h3>Details</h3>
|
||||
<p>The <code>statusCode</code> and <code>headers</code> can also be set within
|
||||
the node itself. If a property is set within the node, it cannot be overridden
|
||||
by the corresponding message property.</p>
|
||||
<h3>Cookie handling</h3>
|
||||
<h4>Cookie handling</h4>
|
||||
<p>The <code>cookies</code> property must be an object of name/value pairs.
|
||||
The value can be either a string to set the value of the cookie with default
|
||||
options, or it can be an object of options.<p>
|
||||
|
Reference in New Issue
Block a user