Mercurial > hg > nginx-site
comparison xml/en/docs/njs/index.xml @ 2556:c81b1fadbcf3
Updated hello_world example in njs.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Fri, 19 Jun 2020 12:48:01 +0100 |
parents | 5b2764724e0d |
children | 8831b3d9f332 |
comparison
equal
deleted
inserted
replaced
2555:5b2764724e0d | 2556:c81b1fadbcf3 |
---|---|
7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> | 7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> |
8 | 8 |
9 <article name="njs scripting language" | 9 <article name="njs scripting language" |
10 link="/en/docs/njs/index.html" | 10 link="/en/docs/njs/index.html" |
11 lang="en" | 11 lang="en" |
12 rev="30" | 12 rev="31" |
13 toc="no"> | 13 toc="no"> |
14 | 14 |
15 <section id="summary"> | 15 <section id="summary"> |
16 | 16 |
17 <para> | 17 <para> |
136 </para> | 136 </para> |
137 </listitem> | 137 </listitem> |
138 | 138 |
139 <listitem id="hello_world"> | 139 <listitem id="hello_world"> |
140 <para> | 140 <para> |
141 create an njs script file, for example, <path>hello_world.js</path>. | 141 create an njs script file, for example, <path>http.js</path>. |
142 See <link doc="reference.xml">Reference</link> | 142 See <link doc="reference.xml">Reference</link> |
143 for the list of njs properties and methods. | 143 for the list of njs properties and methods. |
144 <example> | 144 <example> |
145 function hello(r) { | 145 function hello(r) { |
146 r.return(200, "Hello world!"); | 146 r.return(200, "Hello world!"); |
147 } | 147 } |
148 | |
149 export default {hello}; | |
148 </example> | 150 </example> |
149 </para> | 151 </para> |
150 </listitem> | 152 </listitem> |
151 | 153 |
152 <listitem> | 154 <listitem> |
153 | 155 |
154 <para> | 156 <para> |
155 in the <path>nginx.conf</path> file, enable | 157 in the <path>nginx.conf</path> file, enable |
156 <link doc="../http/ngx_http_js_module.xml">ngx_http_js_module</link> module | 158 <link doc="../http/ngx_http_js_module.xml">ngx_http_js_module</link> module |
157 and specify the | 159 and specify the |
158 <link doc="../http/ngx_http_js_module.xml" id="js_include">js_include</link> | 160 <link doc="../http/ngx_http_js_module.xml" id="js_import">js_import</link> |
159 directive | 161 directive |
160 with the <path>hello_world.js</path> script file: | 162 with the <path>http.js</path> script file: |
161 <example> | 163 <example> |
162 load_module modules/ngx_http_js_module.so; | 164 load_module modules/ngx_http_js_module.so; |
163 | 165 |
164 events {} | 166 events {} |
165 | 167 |
166 http { | 168 http { |
167 js_include hello_world.js; | 169 js_import http.js; |
168 | 170 |
169 server { | 171 server { |
170 listen 8000; | 172 listen 8000; |
171 | 173 |
172 location / { | 174 location / { |
173 js_content hello; | 175 js_content http.hello; |
174 } | 176 } |
175 } | 177 } |
176 } | 178 } |
177 | |
178 </example> | 179 </example> |
179 </para> | 180 </para> |
180 </listitem> | 181 </listitem> |
181 | 182 |
182 </list> | 183 </list> |