annotate xml/en/docs/http/ngx_http_js_module.xml @ 2901:9719a0184a67

Documented the js_preload_object directive.
author Yaroslav Zhuravlev <yar@nginx.com>
date Fri, 21 Oct 2022 12:19:07 +0100
parents 986e1f930e3b
children 7e83ebfac8ca
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
1 <?xml version="1.0"?>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
2
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
3 <!--
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
4 Copyright (C) Nginx, Inc.
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
5 -->
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
6
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
7 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
8
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
9 <module name="Module ngx_http_js_module"
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
10 link="/en/docs/http/ngx_http_js_module.html"
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
11 lang="en"
2901
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
12 rev="37">
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
13
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
14 <section id="summary">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
15
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
16 <para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
17 The <literal>ngx_http_js_module</literal> module is used to implement
1844
f56626ce9c40 Changed JavaScript to nginScript.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1840
diff changeset
18 location and variable handlers
2245
87a0e2c73a25 Refactored njs documentation.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2244
diff changeset
19 in <link doc="../njs/index.xml">njs</link> —
1844
f56626ce9c40 Changed JavaScript to nginScript.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1840
diff changeset
20 a subset of the JavaScript language.
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
21 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
22
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
23 <para>
2188
523dc4cc8745 Updated installation procedure in njs modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2187
diff changeset
24 Download and install instructions are available
2245
87a0e2c73a25 Refactored njs documentation.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2244
diff changeset
25 <link doc="../njs/install.xml">here</link>.
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
26 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
27
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
28 </section>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
29
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
30
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
31 <section id="example" name="Example Configuration">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
32
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
33 <para>
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
34 The example works since
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
35 <link doc="../njs/changes.xml" id="njs0.4.0">0.4.0</link>.
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
36 <example>
2190
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
37 http {
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
38 js_import http.js;
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
39
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
40 js_set $foo http.foo;
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
41 js_set $summary http.summary;
2779
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
42 js_set $hash http.hash;
1858
36cbfff92c6d Restricted context of js_set directive to http and stream only.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1853
diff changeset
43
2784
65591dd31d64 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2779
diff changeset
44 resolver 10.0.0.1;
65591dd31d64 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2779
diff changeset
45
2190
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
46 server {
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
47 listen 8000;
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
48
2190
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
49 location / {
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
50 add_header X-Foo $foo;
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
51 js_content http.baz;
2190
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
52 }
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
53
2206
5cacd6fffade Eliminated some examples of unsafe prefix locations.
Ruslan Ermilov <ru@nginx.com>
parents: 2190
diff changeset
54 location = /summary {
2190
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
55 return 200 $summary;
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
56 }
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
57
2206
5cacd6fffade Eliminated some examples of unsafe prefix locations.
Ruslan Ermilov <ru@nginx.com>
parents: 2190
diff changeset
58 location = /hello {
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
59 js_content http.hello;
2190
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
60 }
2779
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
61
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
62 # since 0.7.0
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
63 location = /fetch {
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
64 js_content http.fetch;
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
65 js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem;
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
66 }
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
67
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
68 # since 0.7.0
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
69 location = /crypto {
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
70 add_header Hash $hash;
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
71 return 200;
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
72 }
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
73 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
74 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
75 </example>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
76 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
77
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
78 <para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
79 The <path>http.js</path> file:
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
80 <example>
2187
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
81 function foo(r) {
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
82 r.log("hello from foo() handler");
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
83 return "foo";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
84 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
85
2187
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
86 function summary(r) {
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
87 var a, s, h;
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
88
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
89 s = "JS summary\n\n";
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
90
2187
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
91 s += "Method: " + r.method + "\n";
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
92 s += "HTTP version: " + r.httpVersion + "\n";
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
93 s += "Host: " + r.headersIn.host + "\n";
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
94 s += "Remote Address: " + r.remoteAddress + "\n";
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
95 s += "URI: " + r.uri + "\n";
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
96
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
97 s += "Headers:\n";
2187
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
98 for (h in r.headersIn) {
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
99 s += " header '" + h + "' is '" + r.headersIn[h] + "'\n";
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
100 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
101
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
102 s += "Args:\n";
2187
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
103 for (a in r.args) {
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
104 s += " arg '" + a + "' is '" + r.args[a] + "'\n";
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
105 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
106
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
107 return s;
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
108 }
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
109
2187
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
110 function baz(r) {
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
111 r.status = 200;
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
112 r.headersOut.foo = 1234;
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
113 r.headersOut['Content-Type'] = "text/plain; charset=utf-8";
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
114 r.headersOut['Content-Length'] = 15;
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
115 r.sendHeader();
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
116 r.send("nginx");
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
117 r.send("java");
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
118 r.send("script");
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
119
2187
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
120 r.finish();
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
121 }
2190
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
122
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
123 function hello(r) {
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
124 r.return(200, "Hello world!");
dfc49994218c Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2188
diff changeset
125 }
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
126
2779
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
127 // since 0.7.0
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
128 async function fetch(r) {
2784
65591dd31d64 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2779
diff changeset
129 let results = await Promise.all([ngx.fetch('https://nginx.org/'),
65591dd31d64 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2779
diff changeset
130 ngx.fetch('https://nginx.org/en/')]);
2779
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
131
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
132 r.return(200, JSON.stringify(results, undefined, 4));
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
133 }
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
134
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
135 // since 0.7.0
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
136 async function hash(r) {
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
137 let hash = await crypto.subtle.digest('SHA-512', r.headersIn.host);
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
138 r.setReturnValue(Buffer.from(hash).toString('hex'));
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
139 }
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
140
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
141 export default {foo, summary, baz, hello, fetch, hash};
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
142 </example>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
143 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
144
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
145 </section>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
146
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
147
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
148 <section id="directives" name="Directives">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
149
2664
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
150 <directive name="js_body_filter">
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
151 <syntax><value>function</value> | <value>module.function</value>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
152 [<value>buffer_type</value>=<value>string</value> | <value>buffer</value>]</syntax>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
153 <default/>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
154 <context>location</context>
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
155 <context>if in location</context>
2664
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
156 <context>limit_except</context>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
157 <appeared-in>0.5.2</appeared-in>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
158
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
159 <para>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
160 Sets an njs function as a response body filter.
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
161 The filter function is called for each data chunk of a response body
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
162 with the following arguments:
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
163
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
164 <list type="tag">
2675
893cd7724c8c Documented the "r" argument for js_body_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2664
diff changeset
165 <tag-name><literal>r</literal></tag-name>
893cd7724c8c Documented the "r" argument for js_body_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2664
diff changeset
166 <tag-desc>
893cd7724c8c Documented the "r" argument for js_body_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2664
diff changeset
167 the <link doc="../njs/reference.xml" id="http">HTTP request</link> object
893cd7724c8c Documented the "r" argument for js_body_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2664
diff changeset
168 </tag-desc>
893cd7724c8c Documented the "r" argument for js_body_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2664
diff changeset
169
2664
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
170 <tag-name><literal>data</literal></tag-name>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
171 <tag-desc>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
172 the incoming data chunk,
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
173 may be a string or Buffer
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
174 depending on the <literal>buffer_type</literal> value,
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
175 by default is a string.
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
176 </tag-desc>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
177
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
178 <tag-name><literal>flags</literal></tag-name>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
179 <tag-desc>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
180 an object with the following properties:
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
181 <list type="tag">
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
182 <tag-name><literal>last</literal></tag-name>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
183 <tag-desc>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
184 a boolean value, true if data is a last buffer.
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
185 </tag-desc>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
186
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
187 </list>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
188 </tag-desc>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
189
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
190 </list>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
191 </para>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
192
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
193 <para>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
194 The filter function can pass its own modified version
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
195 of the input data chunk to the next body filter by calling
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
196 <link doc="../njs/reference.xml" id="r_sendbuffer"><literal>r.sendBuffer()</literal></link>.
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
197 For example, to transform all the lowercase letters in the response body:
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
198 <example>
2675
893cd7724c8c Documented the "r" argument for js_body_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2664
diff changeset
199 function filter(r, data, flags) {
2664
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
200 r.sendBuffer(data.toLowerCase(), flags);
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
201 }
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
202 </example>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
203 To stop filtering (following data chunks will be passed to client
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
204 without calling <literal>js_body_filter</literal>),
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
205 <link doc="../njs/reference.xml" id="r_done"><literal>r.done()</literal></link>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
206 can be used.
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
207 </para>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
208
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
209 <para>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
210 If the filter function changes the length of the response body, then
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
211 it is required to clear out the <header>Content-Length</header> response header
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
212 (if any) in
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
213 <link id="js_header_filter"><literal>js_header_filter</literal></link>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
214 to enforce chunked transfer encoding.
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
215 </para>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
216
2787
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
217 <para>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
218 <note>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
219 As the <literal>js_body_filter</literal> handler
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
220 returns its result immediately, it supports
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
221 only synchronous operations.
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
222 Thus, asynchronous operations such as
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
223 <link doc="../njs/reference.xml" id="r_subrequest">r.subrequest()</link>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
224 or
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
225 <link doc="../njs/reference.xml" id="settimeout">setTimeout()</link>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
226 are not supported.
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
227 </note>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
228 </para>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
229
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
230 <para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
231 <note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
232 The directive can be specified inside the
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
233 <link doc="../http/ngx_http_rewrite_module.xml" id="if">if</link> block
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
234 since <link doc="../njs/changes.xml" id="njs0.7.7">0.7.7</link>.
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
235 </note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
236 </para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
237
2664
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
238 </directive>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
239
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
240
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
241 <directive name="js_content">
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
242 <syntax><value>function</value> | <value>module.function</value></syntax>
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
243 <default/>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
244 <context>location</context>
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
245 <context>if in location</context>
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
246 <context>limit_except</context>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
247
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
248 <para>
2128
59a3cc84f507 Renamed nginScript to njs
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2026
diff changeset
249 Sets an njs function as a location content handler.
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
250 Since <link doc="../njs/changes.xml" id="njs0.4.0">0.4.0</link>,
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
251 a module function can be referenced.
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
252 </para>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
253
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
254 <para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
255 <note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
256 The directive can be specified inside the
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
257 <link doc="../http/ngx_http_rewrite_module.xml" id="if">if</link> block
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
258 since <link doc="../njs/changes.xml" id="njs0.7.7">0.7.7</link>.
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
259 </note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
260 </para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
261
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
262 </directive>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
263
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
264
2845
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
265 <directive name="js_fetch_buffer_size">
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
266 <syntax><value>size</value></syntax>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
267 <default>16k</default>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
268 <context>http</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
269 <context>server</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
270 <context>location</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
271 <appeared-in>0.7.4</appeared-in>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
272
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
273 <para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
274 Sets the <value>size</value> of the buffer used for reading and writing
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
275 with <link doc="../njs/reference.xml" id="ngx_fetch">Fetch API</link>.
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
276 </para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
277
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
278 </directive>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
279
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
280
2773
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
281 <directive name="js_fetch_ciphers">
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
282 <syntax><value>ciphers</value></syntax>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
283 <default>HIGH:!aNULL:!MD5</default>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
284 <context>http</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
285 <context>server</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
286 <context>location</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
287 <appeared-in>0.7.0</appeared-in>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
288
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
289 <para>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
290 Specifies the enabled ciphers for HTTPS requests
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
291 with <link doc="../njs/reference.xml" id="ngx_fetch">Fetch API</link>.
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
292 The ciphers are specified in the format understood by the
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
293 OpenSSL library.
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
294 </para>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
295
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
296 <para>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
297 The full list can be viewed using the
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
298 “<command>openssl ciphers</command>” command.
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
299 </para>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
300
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
301 </directive>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
302
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
303
2845
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
304 <directive name="js_fetch_max_response_buffer_size">
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
305 <syntax><value>size</value></syntax>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
306 <default>1m</default>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
307 <context>http</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
308 <context>server</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
309 <context>location</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
310 <appeared-in>0.7.4</appeared-in>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
311
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
312 <para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
313 Sets the maximum <value>size</value> of the response received
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
314 with <link doc="../njs/reference.xml" id="ngx_fetch">Fetch API</link>.
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
315 </para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
316
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
317 </directive>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
318
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
319
2773
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
320 <directive name="js_fetch_protocols">
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
321 <syntax>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
322 [<literal>TLSv1</literal>]
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
323 [<literal>TLSv1.1</literal>]
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
324 [<literal>TLSv1.2</literal>]
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
325 [<literal>TLSv1.3</literal>]</syntax>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
326 <default>TLSv1 TLSv1.1 TLSv1.2</default>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
327 <context>http</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
328 <context>server</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
329 <context>location</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
330 <appeared-in>0.7.0</appeared-in>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
331
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
332 <para>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
333 Enables the specified protocols for HTTPS requests
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
334 with <link doc="../njs/reference.xml" id="ngx_fetch">Fetch API</link>.
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
335 </para>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
336
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
337 </directive>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
338
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
339
2845
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
340 <directive name="js_fetch_timeout">
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
341 <syntax><value>time</value></syntax>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
342 <default>60s</default>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
343 <context>http</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
344 <context>server</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
345 <context>location</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
346 <appeared-in>0.7.4</appeared-in>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
347
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
348 <para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
349 Defines a timeout for reading and writing
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
350 for <link doc="../njs/reference.xml" id="ngx_fetch">Fetch API</link>.
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
351 The timeout is set only between two successive read/write operations,
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
352 not for the whole response.
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
353 If no data is transmitted within this time, the connection is closed.
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
354 </para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
355
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
356 </directive>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
357
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
358
2773
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
359 <directive name="js_fetch_trusted_certificate">
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
360 <syntax><value>file</value></syntax>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
361 <default/>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
362 <context>http</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
363 <context>server</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
364 <context>location</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
365 <appeared-in>0.7.0</appeared-in>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
366
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
367 <para>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
368 Specifies a <value>file</value> with trusted CA certificates in the PEM format
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
369 used to
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
370 <link doc="../njs/reference.xml" id="fetch_verify">verify</link>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
371 the HTTPS certificate
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
372 with <link doc="../njs/reference.xml" id="ngx_fetch">Fetch API</link>.
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
373 </para>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
374
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
375 </directive>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
376
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
377
2845
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
378 <directive name="js_fetch_verify">
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
379 <syntax><literal>on</literal> | <literal>off</literal></syntax>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
380 <default>on</default>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
381 <context>http</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
382 <context>server</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
383 <context>location</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
384 <appeared-in>0.7.4</appeared-in>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
385
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
386 <para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
387 Enables or disables verification of the HTTPS server certificate
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
388 with <link doc="../njs/reference.xml" id="ngx_fetch">Fetch API</link>.
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
389 </para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
390
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
391 </directive>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
392
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
393
2773
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
394 <directive name="js_fetch_verify_depth">
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
395 <syntax><value>number</value></syntax>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
396 <default>100</default>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
397 <context>http</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
398 <context>server</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
399 <context>location</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
400 <appeared-in>0.7.0</appeared-in>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
401
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
402 <para>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
403 Sets the verification depth in the HTTPS server certificates chain
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
404 with <link doc="../njs/reference.xml" id="ngx_fetch">Fetch API</link>.
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
405 </para>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
406
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
407 </directive>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
408
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
409
2651
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
410 <directive name="js_header_filter">
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
411 <syntax><value>function</value> | <value>module.function</value></syntax>
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
412 <default/>
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
413 <context>location</context>
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
414 <context>if in location</context>
2651
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
415 <context>limit_except</context>
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
416 <appeared-in>0.5.1</appeared-in>
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
417
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
418 <para>
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
419 Sets an njs function as a response header filter.
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
420 The directive allows changing arbitrary header fields of a response header.
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
421 </para>
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
422
2787
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
423 <para>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
424 <note>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
425 As the <literal>js_header_filter</literal> handler
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
426 returns its result immediately, it supports
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
427 only synchronous operations.
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
428 Thus, asynchronous operations such as
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
429 <link doc="../njs/reference.xml" id="r_subrequest">r.subrequest()</link>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
430 or
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
431 <link doc="../njs/reference.xml" id="settimeout">setTimeout()</link>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
432 are not supported.
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
433 </note>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
434 </para>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
435
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
436 <para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
437 <note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
438 The directive can be specified inside the
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
439 <link doc="../http/ngx_http_rewrite_module.xml" id="if">if</link> block
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
440 since <link doc="../njs/changes.xml" id="njs0.7.7">0.7.7</link>.
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
441 </note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
442 </para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
443
2651
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
444 </directive>
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
445
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
446
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
447 <directive name="js_import">
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
448 <syntax><value>module.js</value> |
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
449 <value>export_name from module.js</value></syntax>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
450 <default/>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
451 <context>http</context>
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
452 <context>server</context>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
453 <context>location</context>
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
454 <appeared-in>0.4.0</appeared-in>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
455
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
456 <para>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
457 Imports a module that implements location and variable handlers in njs.
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
458 The <literal>export_name</literal> is used as a namespace
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
459 to access module functions.
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
460 If the <literal>export_name</literal> is not specified,
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
461 the module name will be used as a namespace.
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
462 <example>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
463 js_import http.js;
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
464 </example>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
465 Here, the module name <literal>http</literal> is used as a namespace
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
466 while accessing exports.
2680
8751cab1d562 Corrected example description in js_import.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2675
diff changeset
467 If the imported module exports <literal>foo()</literal>,
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
468 <literal>http.foo</literal> is used to refer to it.
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
469 </para>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
470
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
471 <para>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
472 Several <literal>js_import</literal> directives can be specified.
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
473 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
474
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
475 <para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
476 <note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
477 The directive can be specified on the
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
478 <literal>server</literal> and <literal>location</literal> level
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
479 since <link doc="../njs/changes.xml" id="njs0.7.7">0.7.7</link>.
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
480 </note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
481 </para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
482
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
483 </directive>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
484
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
485
2142
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
486 <directive name="js_include">
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
487 <syntax><value>file</value></syntax>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
488 <default/>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
489 <context>http</context>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
490
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
491 <para>
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
492 Specifies a file that implements location and variable handlers in njs:
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
493 <example>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
494 nginx.conf:
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
495 js_include http.js;
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
496 location /version {
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
497 js_content version;
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
498 }
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
499
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
500 http.js:
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
501 function version(r) {
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
502 r.return(200, njs.version);
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
503 }
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
504 </example>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
505 </para>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
506
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
507 <para>
2823
652356b39f0f Added info about removal of the js_import directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2787
diff changeset
508 The directive was made obsolete in version
652356b39f0f Added info about removal of the js_import directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2787
diff changeset
509 <link doc="../njs/changes.xml" id="njs0.4.0">0.4.0</link>
652356b39f0f Added info about removal of the js_import directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2787
diff changeset
510 and was removed in version
652356b39f0f Added info about removal of the js_import directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2787
diff changeset
511 <link doc="../njs/changes.xml" id="njs0.7.1">0.7.1</link>.
652356b39f0f Added info about removal of the js_import directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2787
diff changeset
512 The <link id="js_import"/> directive should be used instead.
2142
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
513 </para>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
514
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
515 </directive>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
516
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
517
2352
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
518 <directive name="js_path">
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
519 <syntax>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
520 <value>path</value></syntax>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
521 <default/>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
522 <context>http</context>
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
523 <context>server</context>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
524 <context>location</context>
2352
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
525 <appeared-in>0.3.0</appeared-in>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
526
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
527 <para>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
528 Sets an additional path for njs modules.
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
529 </para>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
530
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
531 <para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
532 <note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
533 The directive can be specified on the
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
534 <literal>server</literal> and <literal>location</literal> level
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
535 since <link doc="../njs/changes.xml" id="njs0.7.7">0.7.7</link>.
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
536 </note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
537 </para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
538
2352
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
539 </directive>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
540
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
541
2901
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
542 <directive name="js_preload_object">
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
543 <syntax><value>name.json</value> |
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
544 <value>name</value> from <value>file.json</value></syntax>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
545 <default/>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
546 <context>http</context>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
547 <context>server</context>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
548 <context>location</context>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
549 <appeared-in>0.7.8</appeared-in>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
550
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
551 <para>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
552 Preloads an immutable object at configure time.
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
553 The <literal>name</literal> is used a name of the global variable
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
554 though which the object is available in njs code.
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
555 If the <literal>name</literal> is not specified,
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
556 the file name will be used instead.
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
557 <example>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
558 js_preload_object map.json;
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
559 </example>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
560 Here, the <literal>map</literal> is used as a name
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
561 while accessing the preloaded object.
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
562 </para>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
563
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
564 <para>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
565 Several <literal>js_preload_object</literal> directives can be specified.
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
566 </para>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
567
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
568 </directive>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
569
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
570
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
571 <directive name="js_set">
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
572 <syntax>
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
573 <value>$variable</value> <value>function</value> |
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
574 <value>module.function</value></syntax>
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
575 <default/>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
576 <context>http</context>
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
577 <context>server</context>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
578 <context>location</context>
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
579
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
580 <para>
2686
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
581 Sets an njs <literal>function</literal>
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
582 for the specified <literal>variable</literal>.
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
583 Since <link doc="../njs/changes.xml" id="njs0.4.0">0.4.0</link>,
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
584 a module function can be referenced.
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
585 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
586
2686
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
587 <para>
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
588 The function is called when
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
589 the variable is referenced for the first time for a given request.
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
590 The exact moment depends on a
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
591 <link doc="../dev/development_guide.xml" id="http_phases">phase</link>
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
592 at which the variable is referenced.
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
593 This can be used to perform some logic
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
594 not related to variable evaluation.
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
595 For example, if the variable is referenced only in the
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
596 <link doc="ngx_http_log_module.xml" id="log_format"/> directive,
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
597 its handler will not be executed until the log phase.
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
598 This handler can be used to do some cleanup
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
599 right before the request is freed.
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
600 </para>
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
601
2747
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
602 <para>
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
603 <note>
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
604 As the <literal>js_set</literal> handler
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
605 returns its result immediately, it supports
2787
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
606 only synchronous operations.
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
607 Thus, asynchronous operations such as
2747
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
608 <link doc="../njs/reference.xml" id="r_subrequest">r.subrequest()</link>
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
609 or
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
610 <link doc="../njs/reference.xml" id="settimeout">setTimeout()</link>
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
611 are not supported.
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
612 </note>
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
613 </para>
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
614
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
615 <para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
616 <note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
617 The directive can be specified on the
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
618 <literal>server</literal> and <literal>location</literal> level
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
619 since <link doc="../njs/changes.xml" id="njs0.7.7">0.7.7</link>.
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
620 </note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
621 </para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
622
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
623 </directive>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
624
2693
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
625
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
626 <directive name="js_var">
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
627 <syntax><value>$variable</value> [<value>value</value>]</syntax>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
628 <default/>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
629 <context>http</context>
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
630 <context>server</context>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
631 <context>location</context>
2693
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
632 <appeared-in>0.5.3</appeared-in>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
633
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
634 <para>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
635 Declares
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
636 a <link doc="../njs/reference.xml" id="r_variables">writable</link>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
637 variable.
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
638 The value can contain text, variables, and their combination.
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
639 The variable is not overwritten after a redirect
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
640 unlike variables created with the
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
641 <link doc="ngx_http_rewrite_module.xml" id="set"/> directive.
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
642 </para>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
643
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
644 <para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
645 <note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
646 The directive can be specified on the
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
647 <literal>server</literal> and <literal>location</literal> level
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
648 since <link doc="../njs/changes.xml" id="njs0.7.7">0.7.7</link>.
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
649 </note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
650 </para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
651
2693
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
652 </directive>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
653
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
654 </section>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
655
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
656
2187
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
657 <section id="arguments" name="Request Argument">
2149
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
658
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
659 <para>
2187
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
660 Each HTTP njs handler receives one argument, a request
2246
32ba43abf9cd Renamed njs API, njs Changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2245
diff changeset
661 <link doc="../njs/reference.xml" id="http">object</link>.
1840
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
662 </para>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
663
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
664 </section>
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
665
15632fc2d548 Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
666 </module>