comparison xml/en/docs/http/ngx_http_js_module.xml @ 2149:6df1a86a60b8

Added new njs HTTP properties and methods.
author Roman Arutyunyan <arut@nginx.com>
date Fri, 06 Apr 2018 20:34:26 +0300
parents ca7568f67dee
children cd4889fdcfa4
comparison
equal deleted inserted replaced
2148:94a598ee1d49 2149:6df1a86a60b8
7 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> 7 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
8 8
9 <module name="Module ngx_http_js_module" 9 <module name="Module ngx_http_js_module"
10 link="/en/docs/http/ngx_http_js_module.html" 10 link="/en/docs/http/ngx_http_js_module.html"
11 lang="en" 11 lang="en"
12 rev="9"> 12 rev="10">
13 13
14 <section id="summary"> 14 <section id="summary">
15 15
16 <para> 16 <para>
17 The <literal>ngx_http_js_module</literal> module is used to implement 17 The <literal>ngx_http_js_module</literal> module is used to implement
206 <tag-name><literal>variables{}</literal></tag-name> 206 <tag-name><literal>variables{}</literal></tag-name>
207 <tag-desc> 207 <tag-desc>
208 nginx variables object, read-only 208 nginx variables object, read-only
209 </tag-desc> 209 </tag-desc>
210 210
211 <tag-name><literal>response</literal></tag-name>
212 <tag-desc>
213 the response object (0.2.0), read-only
214 </tag-desc>
215 </list>
216 </para>
217
218 <para>
219 The request object has the following methods:
220 <list type="tag">
221
211 <tag-name><literal>log(<value>string</value>)</literal></tag-name> 222 <tag-name><literal>log(<value>string</value>)</literal></tag-name>
212 <tag-desc> 223 <tag-desc>
213 writes a <literal>string</literal> to the error log 224 writes a <literal>string</literal> to the error log
214 on the <literal>info</literal> level of logging 225 on the <literal>info</literal> level of logging
215 </tag-desc> 226 </tag-desc>
227
228 <tag-name><literal>warn(<value>string</value>)</literal></tag-name>
229 <tag-desc>
230 writes a <literal>string</literal> to the error log
231 on the <literal>warning</literal> level of logging (0.2.0)
232 </tag-desc>
233
234 <tag-name><literal>error(<value>string</value>)</literal></tag-name>
235 <tag-desc>
236 writes a <literal>string</literal> to the error log
237 on the <literal>error</literal> level of logging (0.2.0)
238 </tag-desc>
239
240 <tag-name><literal>subrequest(<value>uri</value>[, <value>options</value>[,
241 <value>callback</value>]])</literal></tag-name>
242 <tag-desc>
243 creates a subrequest with the given <literal>uri</literal> and
244 <literal>options</literal>, and installs
245 an optional completion <literal>callback</literal> (0.2.0).
246
247 <para>
248 If <literal>options</literal> is a string, then it
249 holds the subrequest arguments string.
250 Otherwise <literal>options</literal> is expected to be
251 an object with the following keys:
252 <list type="tag">
253 <tag-name><literal>args</literal></tag-name>
254 <tag-desc>arguments string</tag-desc>
255
256 <tag-name><literal>body</literal></tag-name>
257 <tag-desc>request body</tag-desc>
258
259 <tag-name><literal>method</literal></tag-name>
260 <tag-desc>HTTP method</tag-desc>
261 </list>
262 </para>
263
264 <para>
265 The <literal>callback</literal> receives a response object
266 with the following properties:
267 <literal>uri</literal>, <literal>method</literal>,
268 <literal>status</literal>, <literal>contentType</literal>,
269 <literal>contentLength</literal>, <literal>headers</literal>,
270 <literal>args</literal>.
271 These properties have the same meaning as the request object properties.
272 Additionally, a reply object has the <literal>body</literal> property
273 holding the subrequest response body
274 and the <literal>parent</literal> property
275 referencing the parent request object.
276 </para>
277 </tag-desc>
216 </list> 278 </list>
217 </para> 279 </para>
218 280
219 <para> 281 <para>
220 The response object has the following properties: 282 The response object has the following properties:
258 320
259 <tag-name><literal>finish()</literal></tag-name> 321 <tag-name><literal>finish()</literal></tag-name>
260 <tag-desc> 322 <tag-desc>
261 finishes sending a response to the client 323 finishes sending a response to the client
262 </tag-desc> 324 </tag-desc>
325
326 <tag-name><literal>return(status[, string])</literal></tag-name>
327 <tag-desc>
328 sends
329 the entire response with the specified <literal>status</literal> to the client
330 (0.2.0)
331 <para>
332 It is possible to specify either a redirect URL
333 (for codes 301, 302, 303, 307, and 308)
334 or the response body text (for other codes) as the second argument.
335 </para>
336 </tag-desc>
263 </list> 337 </list>
264 </para> 338 </para>
265 339
266 </section> 340 </section>
267 341