annotate xml/ru/docs/http/ngx_http_js_module.xml @ 3039:e6b785b7e308

Minor fixes in njs documentation.
author Yaroslav Zhuravlev <yar@nginx.com>
date Tue, 06 Feb 2024 08:52:52 +0000
parents 58f0d9d7fe1d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
1 <?xml version="1.0"?>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
2
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
3 <!--
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
4 Copyright (C) Nginx, Inc.
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
5 -->
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
6
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
7 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd">
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
8
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
9 <module name="Модуль ngx_http_js_module"
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
10 link="/ru/docs/http/ngx_http_js_module.html"
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
11 lang="ru"
3039
e6b785b7e308 Minor fixes in njs documentation.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3018
diff changeset
12 rev="46">
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
13
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
14 <section id="summary">
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
15
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
16 <para>
1844
f56626ce9c40 Changed JavaScript to nginScript.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1843
diff changeset
17 Модуль <literal>ngx_http_js_module</literal> позволяет задавать
f56626ce9c40 Changed JavaScript to nginScript.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1843
diff changeset
18 обработчики location и переменных
2245
87a0e2c73a25 Refactored njs documentation.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2244
diff changeset
19 на <link doc="../njs/index.xml">njs</link> —
1844
f56626ce9c40 Changed JavaScript to nginScript.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 1843
diff changeset
20 подмножестве языка JavaScript.
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
21 </para>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
22
3492eb9b8138 Translated http and stream js modules into Russian.
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 Инструкция по сборке и установке доступны
2245
87a0e2c73a25 Refactored njs documentation.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2244
diff changeset
25 <link doc="../njs/install.xml">здесь</link>.
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
26 </para>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
27
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
28 </section>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
29
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
30
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
31 <section id="example" name="Пример конфигурации">
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
32
3492eb9b8138 Translated http and stream js modules into Russian.
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 Пример работает начиная с версии
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>.
1843
3492eb9b8138 Translated http and stream js modules into Russian.
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;
1843
3492eb9b8138 Translated http and stream js modules into Russian.
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;
1843
3492eb9b8138 Translated http and stream js modules into Russian.
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 }
1843
3492eb9b8138 Translated http and stream js modules into Russian.
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 # начиная с версии 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 # начиная с версии 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 }
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
73 }
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
74 }
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
75 </example>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
76 </para>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
77
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
78 <para>
2779
b6bbdce8c659 Updated Example Configuration in ngx_http_js_module.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2773
diff changeset
79 Файл <path>http.js</path>:
1843
3492eb9b8138 Translated http and stream js modules into Russian.
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");
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
83 return "foo";
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
84 }
3492eb9b8138 Translated http and stream js modules into Russian.
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) {
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
87 var a, s, h;
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
88
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
89 s = "JS summary\n\n";
3492eb9b8138 Translated http and stream js modules into Russian.
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";
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
96
3492eb9b8138 Translated http and stream js modules into Russian.
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";
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
100 }
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
101
3492eb9b8138 Translated http and stream js modules into Russian.
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";
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
105 }
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
106
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
107 return s;
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
108 }
3492eb9b8138 Translated http and stream js modules into Russian.
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");
1843
3492eb9b8138 Translated http and stream js modules into Russian.
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();
1843
3492eb9b8138 Translated http and stream js modules into Russian.
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 // начиная с версии 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 // начиная с версии 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};
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
142 </example>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
143 </para>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
144
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
145 </section>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
146
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
147
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
148 <section id="directives" name="Директивы">
3492eb9b8138 Translated http and stream js modules into Russian.
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>функция</value> | <value>модуль.функция</value>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
152 [<value>buffer_type</value>=<value>строка</value> | <value>буфер</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 Задаёт функцию njs в качестве фильтра тела ответа.
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
161 Функция фильтра вызывается для каждого блока данных тела ответа
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
162 со следующими аргументами:
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 объект <link doc="../njs/reference.xml" id="http">HTTP request</link>
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 входящий блок данных
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
173 может быть строкой или буфером
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
174 в зависимости от значения <literal>buffer_type</literal>,
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
175 по умолчанию является строкой.
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 объект со следующими свойствами:
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 логическое значение, true, если данные являются последним буфером.
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 Функция фильтра может передавать свою модифицированную версию
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
195 входящего блока данных следующему фильтру тела ответа при помощи вызова
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 Пример преобразования букв в нижний регистр в теле ответа:
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 Для отмены фильтра (блоки данных будут передаваться клиенту
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
204 без вызова <literal>js_body_filter</literal>),
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
205 можно использовать
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
206 <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
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 Если функция фильтра изменяет длину тела ответа, то
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
211 необходимо очистить заголовок ответа <header>Content-Length</header>
9e39e64bff84 Documented the js_body_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2651
diff changeset
212 (если присутствует) в
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 чтобы применить поблочное кодирование.
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 Так как обработчик <literal>js_body_filter</literal>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
220 должен сразу возвращать результат,
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
221 то поддерживаются только синхронные операции,
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
222 Таким образом, асинхронные операции, например
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 или
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 не поддерживаются.
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 Директива может быть указана внутри
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>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
234 начиная с <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
2142
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
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>функция</value> | <value>модуль.функция</value></syntax>
2142
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
243 <default/>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
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>
2142
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
246 <context>limit_except</context>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
247
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
248 <para>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
249 Задаёт функцию njs в качестве обработчика содержимого location.
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
250 Начиная с версии <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 можно ссылаться на функцию модуля.
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 Директива может быть указана внутри
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>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
258 начиная с <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: 2832
diff changeset
265 <directive name="js_fetch_buffer_size">
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
266 <syntax><value>размер</value></syntax>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
267 <default>16k</default>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
268 <context>http</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
269 <context>server</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
270 <context>location</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
271 <appeared-in>0.7.4</appeared-in>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
272
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
273 <para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
274 Задаёт <value>размер</value> буфера, который будет использоваться
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
275 для чтения и записи для
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
276 <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: 2832
diff changeset
277 </para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
278
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
279 </directive>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
280
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
281
2773
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
282 <directive name="js_fetch_ciphers">
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
283 <syntax><value>шифры</value></syntax>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
284 <default>HIGH:!aNULL:!MD5</default>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
285 <context>http</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
286 <context>server</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
287 <context>location</context>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
288 <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
289
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
290 <para>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
291 Описывает разрешённые шифры для HTTPS-запросов
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
292 при помощи <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
293 Шифры задаются в формате, поддерживаемом библиотекой OpenSSL.
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 Полный список можно посмотреть с помощью команды
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
298 “<command>openssl ciphers</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: 2832
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: 2832
diff changeset
305 <syntax><value>размер</value></syntax>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
306 <default>1m</default>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
307 <context>http</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
308 <context>server</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
309 <context>location</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
310 <appeared-in>0.7.4</appeared-in>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
311
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
312 <para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
313 Задаёт максимальный <value>размер</value> ответа, полученного
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
314 при помощи <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: 2832
diff changeset
315 </para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
316
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
317 </directive>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
318
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
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 Разрешает указанные протоколы для HTTPS-запросов
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
334 при помощи <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: 2832
diff changeset
340 <directive name="js_fetch_timeout">
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
341 <syntax><value>время</value></syntax>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
342 <default>60s</default>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
343 <context>http</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
344 <context>server</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
345 <context>location</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
346 <appeared-in>0.7.4</appeared-in>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
347
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
348 <para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
349 Задаёт таймаут при чтении и записи
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
350 при помощи <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: 2832
diff changeset
351 Таймаут устанавливается не на всю передачу ответа,
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
352 а только между двумя операциями чтения.
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
353 Если по истечении этого времени данные не передавались, соединение закрывается.
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
354 </para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
355
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
356 </directive>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
357
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
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>файл</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 Задаёт <value>файл</value> с доверенными сертификатами CA в формате PEM,
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
369 используемыми при
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">проверке</link>
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
371 HTTPS-сертификата
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
372 при помощи <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: 2832
diff changeset
378 <directive name="js_fetch_verify">
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
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: 2832
diff changeset
380 <default>on</default>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
381 <context>http</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
382 <context>server</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
383 <context>location</context>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
384 <appeared-in>0.7.4</appeared-in>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
385
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
386 <para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
387 Разрешает или запрещает проверку сертификата HTTPS-сервера
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
388 при помощи <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: 2832
diff changeset
389 </para>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
390
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
391 </directive>
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
diff changeset
392
a3aee2697d4e Documented directives for Fetch API in njs.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2832
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>число</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 Устанавливает глубину проверки в цепочке HTTPS-сертификатов
a2852750c379 Added fetch directives to js http and stream modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2747
diff changeset
404 при помощи <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>функция</value> | <value>модуль.функция</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 Задаёт функцию njs в качестве фильтра заголовка ответа.
b4991bbd64ee Documented the js_header_filter directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2534
diff changeset
420 Директива позволяет менять произвольные поля заголовка ответа.
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 Так как обработчик <literal>js_header_filter</literal>
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
426 должен сразу возвращать результат,
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
427 то поддерживаются только синхронные операции,
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
428 Таким образом, асинхронные операции, например
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 или
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 не поддерживаются.
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 Директива может быть указана внутри
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>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
440 начиная с <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>модуль.js</value> |
2832
a3992db1d3d4 Corrected syntax of js_import in the Russian translation.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2823
diff changeset
449 <value>имя_экспорта from модуль.js</value></syntax>
2530
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 Импортирует модуль, позволяющий задавать обработчики location и переменных
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
458 на njs.
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
459 <literal>Имя_экспорта</literal> является пространством имён
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
460 при доступе к функциям модуля.
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
461 Если <literal>имя_экспорта</literal> не задано,
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
462 то пространством имён будет являться имя модуля.
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
463 <example>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
464 js_import http.js;
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
465 </example>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
466 В примере при доступе к экспорту в качестве
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
467 пространства имён используется имя модуля <literal>http</literal>.
2680
8751cab1d562 Corrected example description in js_import.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2675
diff changeset
468 Если импортируемый модуль экспортирует <literal>foo()</literal>,
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
469 то для доступа используется <literal>http.foo</literal>.
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
470 </para>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
471
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
472 <para>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
473 Директив <literal>js_import</literal> может быть несколько.
2142
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
474 </para>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
475
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
476 <para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
477 <note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
478 Директива может быть указана
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
479 на уровне <literal>server</literal> и <literal>location</literal>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
480 начиная с <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
481 </note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
482 </para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
483
2142
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
484 </directive>
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
485
ca7568f67dee Sorted directives alphabetically.
Ruslan Ermilov <ru@nginx.com>
parents: 2135
diff changeset
486
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
487 <directive name="js_include">
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
488 <syntax><value>файл</value></syntax>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
489 <default/>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
490 <context>http</context>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
491
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
492 <para>
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
493 Задаёт файл, позволяющий задавать обработчики location и переменных на njs:
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
494 <example>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
495 nginx.conf:
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
496 js_include http.js;
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
497 location /version {
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
498 js_content version;
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
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
501 http.js:
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
502 function version(r) {
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
503 r.return(200, njs.version);
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
504 }
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
505 </example>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
506 </para>
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
507
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
508 <para>
2823
652356b39f0f Added info about removal of the js_import directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2787
diff changeset
509 Директива устарела в версии
652356b39f0f Added info about removal of the js_import directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2787
diff changeset
510 <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
511 и была удалена в версии
652356b39f0f Added info about removal of the js_import directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2787
diff changeset
512 <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
513 Вместо неё следует использовать директиву <link id="js_import"/>.
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
514 </para>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
515
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
516 </directive>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
517
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
518
2352
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
519 <directive name="js_path">
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
520 <syntax>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
521 <value>путь</value></syntax>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
522 <default/>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
523 <context>http</context>
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
524 <context>server</context>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
525 <context>location</context>
2352
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
526 <appeared-in>0.3.0</appeared-in>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
527
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
528 <para>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
529 Задаёт дополнительный путь для модулей njs.
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
530 </para>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
531
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
532 <para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
533 <note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
534 Директива может быть указана
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
535 на уровне <literal>server</literal> и <literal>location</literal>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
536 начиная с <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
537 </note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
538 </para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
539
2352
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
540 </directive>
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
541
1101e24c6d14 Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2288
diff changeset
542
3008
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
543 <directive name="js_periodic">
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
544 <syntax><value>функция</value> |
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
545 <value>модуль.функция</value>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
546 [<literal>interval</literal>=<value>время</value>]
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
547 [<literal>jitter</literal>=<value>число</value>]
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
548 [<literal>worker_affinity</literal>=<value>маска</value>]</syntax>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
549 <default/>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
550 <context>location</context>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
551 <appeared-in>0.8.1</appeared-in>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
552
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
553 <para>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
554 Задаёт периодичность запуска обработчика содержимого.
3014
c0a4a4a55e45 Documented Periodic Session object in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3011
diff changeset
555 В качестве первого аргумента обработчик получает
c0a4a4a55e45 Documented Periodic Session object in njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3011
diff changeset
556 <link doc="../njs/reference.xml" id="periodic_session">объект сессии</link>,
3008
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
557 также у обработчика есть доступ к глобальным объектам таким как
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
558 <link doc="../njs/reference.xml" id="ngx">ngx</link>.
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
559 </para>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
560
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
561 <para>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
562 Необязательный параметр <literal>interval</literal>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
563 задаёт интервал между двумя последовательными запусками,
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
564 по умолчанию 5 секунд.
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
565 </para>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
566
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
567 <para>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
568 Необязательный параметр <literal>jitter</literal>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
569 задаёт время, в пределах которого
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
570 случайным образом задерживается каждый запуск,
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
571 по умолчанию задержки нет.
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
572 </para>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
573
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
574 <para>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
575 По умолчанию <literal>js_handler</literal> выполняется для рабочего процесса 0.
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
576 Необязательный параметр <literal>worker_affinity</literal>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
577 позволяет указать рабочий процесс,
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
578 для которого будет выполняться обработчик содержимого location.
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
579 Рабочие процессы задаются битовой маской разрешённых к использованию рабочих
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
580 процессов.
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
581 Маска <literal>all</literal> позволяет обработчику выполняться
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
582 для всех рабочих процессов.
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
583 </para>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
584
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
585 <para>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
586 Пример:
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
587 <example>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
588 example.conf:
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
589
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
590 location @periodics {
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
591 # интервал выполнения 1 минута для рабочего процесса 0
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
592 js_periodic main.handler interval=60s;
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
593
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
594 # интервал выполнения 1 минута для всех рабочих процессов
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
595 js_periodic main.handler interval=60s worker_affinity=all;
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
596
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
597 # интервал выполнения 1 минута для рабочих процессов 1 и 3
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
598 js_periodic main.handler interval=60s worker_affinity=0101;
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
599
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
600 resolver 10.0.0.1;
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
601 js_fetch_trusted_certificate /path/to/ISRG_Root_X1.pem;
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
602 }
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
603
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
604 example.js:
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
605
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
606 async function handler(s) {
3011
55d49eb065ac Fixed example in the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3008
diff changeset
607 let reply = await ngx.fetch('https://nginx.org/en/docs/njs/');
55d49eb065ac Fixed example in the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3008
diff changeset
608 let body = await reply.text();
3008
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
609
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
610 ngx.log(ngx.INFO, body);
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
611 }
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
612 </example>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
613 </para>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
614
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
615 </directive>
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
616
4470b2bff7b7 Documented the js_periodic directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3007
diff changeset
617
2901
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
618 <directive name="js_preload_object">
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
619 <syntax><value>имя.json</value> |
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
620 <value>имя</value> from <value>файл.json</value></syntax>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
621 <default/>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
622 <context>http</context>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
623 <context>server</context>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
624 <context>location</context>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
625 <appeared-in>0.7.8</appeared-in>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
626
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
627 <para>
2996
98bd95a5ac70 Added link to Preload Objects from js_preload_object.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2990
diff changeset
628 Предварительно загружает
98bd95a5ac70 Added link to Preload Objects from js_preload_object.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2990
diff changeset
629 <link doc="../njs/preload_objects.xml">неизменяемый объект</link>
98bd95a5ac70 Added link to Preload Objects from js_preload_object.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2990
diff changeset
630 во время конфигурации.
2901
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
631 <literal>Имя</literal> используется в качестве имени глобальной переменной,
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
632 через которую объект доступен в коде njs.
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
633 Если <literal>имя</literal> не указано,
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
634 то будет использоваться имя файла.
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
635 <example>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
636 js_preload_object map.json;
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
637 </example>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
638 В примере <literal>map</literal> используется в качестве имени
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
639 во время доступа к предварительно загруженному объекту.
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
640 </para>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
641
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
642 <para>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
643 Директив <literal>js_preload_object</literal> может быть несколько.
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
644 </para>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
645
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
646 </directive>
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
647
9719a0184a67 Documented the js_preload_object directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2882
diff changeset
648
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
649 <directive name="js_set">
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
650 <syntax>
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
651 <value>$переменная</value> <value>функция</value> |
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
652 <value>модуль.функция</value></syntax>
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
653 <default/>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
654 <context>http</context>
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
655 <context>server</context>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
656 <context>location</context>
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
657
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
658 <para>
2686
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
659 Задаёт <literal>функцию</literal> njs
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
660 для указанной <literal>переменной</literal>.
2530
407c5bd5bffc Documented the js_import directive and corresponding changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2352
diff changeset
661 Начиная с <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
662 можно ссылаться на функцию модуля.
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
663 </para>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
664
2686
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
665 <para>
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
666 Функция вызывается в момент
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
667 первого обращения к переменной для данного запроса.
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
668 Точный момент вызова функции зависит от
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
669 <link doc="../dev/development_guide.xml" id="http_phases">фазы</link>,
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
670 в которой происходит обращение к переменной.
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
671 Это можно использовать для реализации дополнительной логики,
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
672 не относящейся к вычислению переменной.
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
673 Например, если переменная указана
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
674 в директиве <link doc="ngx_http_log_module.xml" id="log_format"/>,
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
675 то её обработчик не будет выполняться до фазы записи в лог.
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
676 Этот обработчик также может использоваться для выполнения процедур
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
677 непосредственно перед освобождением запроса.
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
678 </para>
45214e5316cd Improved description of js_set.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2680
diff changeset
679
2747
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
680 <para>
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
681 <note>
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
682 Так как обработчик <literal>js_set</literal>
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
683 должен сразу возвращать результат,
2787
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
684 то поддерживаются только синхронные операции,
005b056c267f Added note about async calls for js_body_filter, js_header_filter.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2784
diff changeset
685 Таким образом, асинхронные операции, например
2747
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
686 <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
687 или
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
688 <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
689 не поддерживаются.
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
690 </note>
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
691 </para>
42fb92e582db Added note to js_set about asyncronous calls.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2693
diff changeset
692
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
693 <para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
694 <note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
695 Директива может быть указана
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
696 на уровне <literal>server</literal> и <literal>location</literal>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
697 начиная с <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
698 </note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
699 </para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
700
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
701 </directive>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
702
2693
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
703
2990
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
704 <directive name="js_shared_dict_zone">
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
705 <syntax>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
706 <literal>zone</literal>=<value>имя</value>:<value>размер</value>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
707 [<literal>timeout</literal>=<value>время</value>]
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
708 [<literal>type</literal>=<literal>строка</literal>|<literal>число</literal>]
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
709 [<literal>evict</literal>]</syntax>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
710 <default/>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
711 <context>http</context>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
712 <appeared-in>0.8.0</appeared-in>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
713
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
714 <para>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
715 Задаёт <value>имя</value> и <value>размер</value> зоны разделяемой памяти,
3007
3184864bbb3f Added SharedDict to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3000
diff changeset
716 в которой хранится
3184864bbb3f Added SharedDict to njs Reference.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 3000
diff changeset
717 <link doc="../njs/reference.xml" id="dict">словарь</link> ключей и значений,
2990
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
718 разделяемый между рабочими процессами.
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
719 </para>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
720
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
721 <para>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
722 По умолчанию в качестве ключа и значения используется строка.
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
723 Необязательный параметр <literal>type</literal>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
724 позволяет изменить тип значения на число.
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
725 </para>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
726
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
727 <para>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
728 Необязательный параметр <literal>timeout</literal> задаёт время,
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
729 по завершении которого все записи в словаре удаляются из зоны.
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
730 </para>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
731
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
732 <para>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
733 Необязательный параметр <literal>evict</literal> удаляет самую старую
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
734 пару ключ-значение при переполнении зоны.
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
735 </para>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
736
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
737 <para>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
738 Пример:
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
739 <example>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
740 example.conf:
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
741 # Создаётся словарь размером 1Мб со строковыми значениями,
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
742 # пары ключ-значение удаляются при отсутствии активности в течение 60 секунд:
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
743 js_shared_dict_zone zone=foo:1M timeout=60s;
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
744
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
745 # Создаётся словарь размером 512Кб со строковыми значениями,
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
746 # удаляется самая старая пара ключ-значение при переполнении зоны:
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
747 js_shared_dict_zone zone=bar:512K timeout=30s evict;
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
748
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
749 # Создаётся постоянный словарь размером 32Кб с числовыми значениями:
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
750 js_shared_dict_zone zone=num:32k type=number;
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
751
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
752 example.js:
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
753 function get(r) {
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
754 r.return(200, ngx.shared.foo.get(r.args.key));
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
755 }
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
756
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
757 function set(r) {
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
758 r.return(200, ngx.shared.foo.set(r.args.key, r.args.value));
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
759 }
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
760
3000
7eafa16bb07c Replaced "delete" to "del" in js_shared_dict_zone.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2996
diff changeset
761 function del(r) {
2990
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
762 r.return(200, ngx.shared.bar.delete(r.args.key));
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
763 }
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
764
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
765 function increment(r) {
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
766 r.return(200, ngx.shared.num.incr(r.args.key, 2));
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
767 }
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
768 </example>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
769 </para>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
770
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
771 </directive>
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
772
7e83ebfac8ca Documented the js_shared_dict_zone directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2901
diff changeset
773
2693
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
774 <directive name="js_var">
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
775 <syntax><value>$переменная</value> [<value>значение</value>]</syntax>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
776 <default/>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
777 <context>http</context>
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
778 <context>server</context>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
779 <context>location</context>
2693
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
780 <appeared-in>0.5.3</appeared-in>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
781
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
782 <para>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
783 Объявляет
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
784 <link doc="../njs/reference.xml" id="r_variables">перезаписываемую</link>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
785 переменную.
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
786 В качестве значения можно использовать текст, переменные и их комбинации.
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
787 Переменная не перезаписывается после перенаправления,
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
788 в отличие от переменных, созданных при помощи
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
789 директивы <link doc="ngx_http_rewrite_module.xml" id="set"/>.
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
790 </para>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
791
2882
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
792 <para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
793 <note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
794 Директива может быть указана
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
795 на уровне <literal>server</literal> и <literal>location</literal>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
796 начиная с <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
797 </note>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
798 </para>
986e1f930e3b Documented server, location, if contexts for some js directives.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2845
diff changeset
799
2693
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
800 </directive>
3cbd6e440581 Documented the js_var directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2686
diff changeset
801
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
802 </section>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
803
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
804
2187
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
805 <section id="arguments" name="Аргумент запроса">
2149
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
806
6df1a86a60b8 Added new njs HTTP properties and methods.
Roman Arutyunyan <arut@nginx.com>
parents: 2142
diff changeset
807 <para>
2187
ed905ab118c7 Updated HTTP njs module according to njs 0.2.2.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2175
diff changeset
808 Каждый HTTP-обработчик njs получает один аргумент,
2288
786e96c52c7a Corrected links and example in Russian http and stream js modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents: 2246
diff changeset
809 <link doc="../njs/reference.xml" id="http">объект</link> запроса.
1843
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
810 </para>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
811
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
812 </section>
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
813
3492eb9b8138 Translated http and stream js modules into Russian.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff changeset
814 </module>