Mercurial > hg > nginx-site
annotate xml/en/docs/stream/ngx_stream_js_module.xml @ 2466:d4be176c6345
njs-0.3.7
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Tue, 19 Nov 2019 17:37:00 +0300 |
parents | 1101e24c6d14 |
children | 407c5bd5bffc |
rev | line source |
---|---|
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
1 <?xml version="1.0"?> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
2 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
3 <!-- |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
4 Copyright (C) Nginx, Inc. |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
5 --> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
6 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
7 <!DOCTYPE module SYSTEM "../../../../dtd/module.dtd"> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
8 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
9 <module name="Module ngx_stream_js_module" |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
10 link="/en/docs/stream/ngx_stream_js_module.html" |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
11 lang="en" |
2352
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
12 rev="17"> |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
13 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
14 <section id="summary"> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
15 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
16 <para> |
1844
f56626ce9c40
Changed JavaScript to nginScript.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1840
diff
changeset
|
17 The <literal>ngx_stream_js_module</literal> module is used to implement |
2245
87a0e2c73a25
Refactored njs documentation.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2244
diff
changeset
|
18 handlers in <link doc="../njs/index.xml">njs</link> — |
1844
f56626ce9c40
Changed JavaScript to nginScript.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1840
diff
changeset
|
19 a subset of the JavaScript language. |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
20 </para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
21 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
22 <para> |
2188
523dc4cc8745
Updated installation procedure in njs modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2175
diff
changeset
|
23 This module is not built by default. |
523dc4cc8745
Updated installation procedure in njs modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2175
diff
changeset
|
24 Download and install instructions are available |
2245
87a0e2c73a25
Refactored njs documentation.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2244
diff
changeset
|
25 <link doc="../njs/install.xml">here</link>. |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
26 </para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
27 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
28 </section> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
29 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
30 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
31 <section id="example" name="Example Configuration"> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
32 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
33 <para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
34 <example> |
2190
dfc49994218c
Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2188
diff
changeset
|
35 load_module modules/ngx_stream_js_module.so; |
dfc49994218c
Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2188
diff
changeset
|
36 ... |
dfc49994218c
Updated example in HTTP njs module.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2188
diff
changeset
|
37 |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
38 stream { |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
39 js_include stream.js; |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
40 |
1858
36cbfff92c6d
Restricted context of js_set directive to http and stream only.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1853
diff
changeset
|
41 js_set $bar bar; |
2237
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
42 js_set $req_line req_line; |
1858
36cbfff92c6d
Restricted context of js_set directive to http and stream only.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
1853
diff
changeset
|
43 |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
44 server { |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
45 listen 12345; |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
46 |
2237
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
47 js_preread preread; |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
48 return $req_line; |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
49 } |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
50 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
51 server { |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
52 listen 12346; |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
53 |
2237
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
54 js_access access; |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
55 proxy_pass 127.0.0.1:8000; |
2237
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
56 js_filter header_inject; |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
57 } |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
58 } |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
59 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
60 http { |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
61 server { |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
62 listen 8000; |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
63 location / { |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
64 return 200 $http_foo\n; |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
65 } |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
66 } |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
67 } |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
68 </example> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
69 </para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
70 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
71 <para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
72 The <path>stream.js</path> file: |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
73 <example> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
74 var line = ''; |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
75 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
76 function bar(s) { |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
77 var v = s.variables; |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
78 s.log("hello from bar() handler!"); |
2237
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
79 return "bar-var" + v.remote_port + "; pid=" + v.pid; |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
80 } |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
81 |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
82 function preread(s) { |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
83 s.on('upload', function (data, flags) { |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
84 var n = data.indexOf('\n'); |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
85 if (n != -1) { |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
86 line = data.substr(0, n); |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
87 s.done(); |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
88 } |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
89 }); |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
90 } |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
91 |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
92 function req_line(s) { |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
93 return line; |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
94 } |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
95 |
2237
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
96 // Read HTTP request line. |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
97 // Collect bytes in 'req' until |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
98 // request line is read. |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
99 // Injects HTTP header into a client's request |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
100 |
2237
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
101 var my_header = 'Foo: foo'; |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
102 function header_inject(s) { |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
103 var req = ''; |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
104 s.on('upload', function(data, flags) { |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
105 req += data; |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
106 var n = req.search('\n'); |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
107 if (n != -1) { |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
108 var rest = req.substr(n + 1); |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
109 req = req.substr(0, n + 1); |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
110 s.send(req + my_header + '\r\n' + rest, flags); |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
111 s.off('upload'); |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
112 } |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
113 }); |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
114 } |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
115 |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
116 function access(s) { |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
117 if (s.remoteAddress.match('^192.*')) { |
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
118 s.abort(); |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
119 return; |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
120 } |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
121 |
2237
5268c13196f2
Documented njs changes triggered by njs-0.2.4.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2190
diff
changeset
|
122 s.allow(); |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
123 } |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
124 </example> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
125 </para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
126 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
127 </section> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
128 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
129 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
130 <section id="directives" name="Directives"> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
131 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
132 <directive name="js_access"> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
133 <syntax><value>function</value></syntax> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
134 <default/> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
135 <context>stream</context> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
136 <context>server</context> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
137 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
138 <para> |
2128
59a3cc84f507
Renamed nginScript to njs
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2026
diff
changeset
|
139 Sets an njs function which will be called at the |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
140 <link doc="stream_processing.xml" id="access_phase">access</link> phase. |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
141 </para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
142 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
143 </directive> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
144 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
145 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
146 <directive name="js_filter"> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
147 <syntax><value>function</value></syntax> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
148 <default/> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
149 <context>stream</context> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
150 <context>server</context> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
151 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
152 <para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
153 Sets a data filter. |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
154 </para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
155 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
156 </directive> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
157 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
158 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
159 <directive name="js_include"> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
160 <syntax><value>file</value></syntax> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
161 <default/> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
162 <context>stream</context> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
163 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
164 <para> |
2128
59a3cc84f507
Renamed nginScript to njs
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2026
diff
changeset
|
165 Specifies a file that implements server and variable handlers in njs. |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
166 </para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
167 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
168 </directive> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
169 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
170 |
2352
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
171 <directive name="js_path"> |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
172 <syntax> |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
173 <value>path</value></syntax> |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
174 <default/> |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
175 <context>http</context> |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
176 <appeared-in>0.3.0</appeared-in> |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
177 |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
178 <para> |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
179 Sets an additional path for njs modules. |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
180 </para> |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
181 |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
182 </directive> |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
183 |
1101e24c6d14
Documented the js_path directive.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2332
diff
changeset
|
184 |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
185 <directive name="js_preread"> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
186 <syntax><value>function</value></syntax> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
187 <default/> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
188 <context>stream</context> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
189 <context>server</context> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
190 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
191 <para> |
2128
59a3cc84f507
Renamed nginScript to njs
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2026
diff
changeset
|
192 Sets an njs function which will be called at the |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
193 <link doc="stream_processing.xml" id="preread_phase">preread</link> phase. |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
194 </para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
195 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
196 </directive> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
197 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
198 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
199 <directive name="js_set"> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
200 <syntax> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
201 <value>$variable</value> <value>function</value></syntax> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
202 <default/> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
203 <context>stream</context> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
204 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
205 <para> |
2128
59a3cc84f507
Renamed nginScript to njs
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2026
diff
changeset
|
206 Sets an njs function for the specified variable. |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
207 </para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
208 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
209 </directive> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
210 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
211 </section> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
212 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
213 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
214 <section id="properties" name="Session Object Properties"> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
215 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
216 <para> |
2175
cd4889fdcfa4
Moved njs HTTP and Stream API to a separate page.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2135
diff
changeset
|
217 Each stream njs handler receives one argument, a stream session |
2246
32ba43abf9cd
Renamed njs API, njs Changes.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
2245
diff
changeset
|
218 <link doc="../njs/reference.xml" id="stream">object</link>. |
1840
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
219 </para> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
220 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
221 </section> |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
222 |
15632fc2d548
Documented http and stream nginScript modules.
Yaroslav Zhuravlev <yar@nginx.com>
parents:
diff
changeset
|
223 </module> |