diff xml/en/docs/http/ngx_http_js_module.xml @ 2187:ed905ab118c7

Updated HTTP njs module according to njs 0.2.2.
author Yaroslav Zhuravlev <yar@nginx.com>
date Tue, 19 Jun 2018 20:43:33 +0300
parents cd4889fdcfa4
children 523dc4cc8745
line wrap: on
line diff
--- a/xml/en/docs/http/ngx_http_js_module.xml
+++ b/xml/en/docs/http/ngx_http_js_module.xml
@@ -9,7 +9,7 @@
 <module name="Module ngx_http_js_module"
         link="/en/docs/http/ngx_http_js_module.html"
         lang="en"
-        rev="11">
+        rev="12">
 
 <section id="summary">
 
@@ -70,46 +70,46 @@ server {
 <para>
 The <path>http.js</path> file:
 <example>
-function foo(req, res) {
-    req.log("hello from foo() handler");
+function foo(r) {
+    r.log("hello from foo() handler");
     return "foo";
 }
 
-function summary(req, res) {
+function summary(r) {
     var a, s, h;
 
     s = "JS summary\n\n";
 
-    s += "Method: " + req.method + "\n";
-    s += "HTTP version: " + req.httpVersion + "\n";
-    s += "Host: " + req.headers.host + "\n";
-    s += "Remote Address: " + req.remoteAddress + "\n";
-    s += "URI: " + req.uri + "\n";
+    s += "Method: " + r.method + "\n";
+    s += "HTTP version: " + r.httpVersion + "\n";
+    s += "Host: " + r.headersIn.host + "\n";
+    s += "Remote Address: " + r.remoteAddress + "\n";
+    s += "URI: " + r.uri + "\n";
 
     s += "Headers:\n";
-    for (h in req.headers) {
-        s += "  header '" + h + "' is '" + req.headers[h] + "'\n";
+    for (h in r.headersIn) {
+        s += "  header '" + h + "' is '" + r.headersIn[h] + "'\n";
     }
 
     s += "Args:\n";
-    for (a in req.args) {
-        s += "  arg '" + a + "' is '" + req.args[a] + "'\n";
+    for (a in r.args) {
+        s += "  arg '" + a + "' is '" + r.args[a] + "'\n";
     }
 
     return s;
 }
 
-function baz(req, res) {
-    res.headers.foo = 1234;
-    res.status = 200;
-    res.contentType = "text/plain; charset=utf-8";
-    res.contentLength = 15;
-    res.sendHeader();
-    res.send("nginx");
-    res.send("java");
-    res.send("script");
+function baz(r) {
+    r.status = 200;
+    r.headersOut.foo = 1234;
+    r.headersOut['Content-Type'] = "text/plain; charset=utf-8";
+    r.headersOut['Content-Length'] = 15;
+    r.sendHeader();
+    r.send("nginx");
+    r.send("java");
+    r.send("script");
 
-    res.finish();
+    r.finish();
 }
 </example>
 </para>
@@ -159,12 +159,11 @@ Sets an njs function for the specified v
 </section>
 
 
-<section id="arguments" name="Request and Response Arguments">
+<section id="arguments" name="Request Argument">
 
 <para>
-Each HTTP njs handler receives two arguments,
-<link doc="../njs/njs_api.xml" id="http_request">request</link>
-and <link doc="../njs/njs_api.xml" id="http_response">response</link>.
+Each HTTP njs handler receives one argument, a request
+<link doc="../njs/njs_api.xml" id="http_request">object</link>.
 </para>
 
 </section>