# HG changeset patch # User Yaroslav Zhuravlev # Date 1592567281 -3600 # Node ID c81b1fadbcf3142c2bc6773ad012774e1e4af72e # Parent 5b2764724e0dc31ae694aa59389631e9b0da1a32 Updated hello_world example in njs. diff --git a/xml/en/docs/njs/examples.xml b/xml/en/docs/njs/examples.xml --- a/xml/en/docs/njs/examples.xml +++ b/xml/en/docs/njs/examples.xml @@ -9,7 +9,7 @@
+ rev="15">
@@ -30,9 +30,15 @@ events {} http { js_import http.js; - js_content http.hello; + + server { + listen 8000; + + location / { + js_content http.hello; + } + } } - diff --git a/xml/en/docs/njs/index.xml b/xml/en/docs/njs/index.xml --- a/xml/en/docs/njs/index.xml +++ b/xml/en/docs/njs/index.xml @@ -9,7 +9,7 @@
@@ -138,13 +138,15 @@ To use njs in nginx: -create an njs script file, for example, hello_world.js. +create an njs script file, for example, http.js. See Reference for the list of njs properties and methods. function hello(r) { r.return(200, "Hello world!"); } + +export default {hello}; @@ -155,26 +157,25 @@ function hello(r) { in the nginx.conf file, enable ngx_http_js_module module and specify the -js_include +js_import directive -with the hello_world.js script file: +with the http.js script file: load_module modules/ngx_http_js_module.so; events {} http { - js_include hello_world.js; + js_import http.js; server { listen 8000; location / { - js_content hello; + js_content http.hello; } } } - diff --git a/xml/ru/docs/njs/examples.xml b/xml/ru/docs/njs/examples.xml --- a/xml/ru/docs/njs/examples.xml +++ b/xml/ru/docs/njs/examples.xml @@ -9,7 +9,7 @@
+ rev="15">
@@ -29,9 +29,15 @@ events {} http { js_import http.js; - js_content http.hello; + + server { + listen 8000; + + location / { + js_content http.hello; + } + } } - diff --git a/xml/ru/docs/njs/index.xml b/xml/ru/docs/njs/index.xml --- a/xml/ru/docs/njs/index.xml +++ b/xml/ru/docs/njs/index.xml @@ -9,7 +9,7 @@
@@ -139,13 +139,15 @@ ngx_stream_js_module -создать файл сценария njs, например hello_world.js. +создать файл сценария njs, например http.js. Описание свойств и методов языка njs см. в справочнике. function hello(r) { r.return(200, "Hello world!"); } + +export default {hello}; @@ -156,25 +158,24 @@ function hello(r) { в файле nginx.conf включить модуль ngx_http_js_module и указать директиву -js_include -с файлом сценария hello_world.js: +js_import +с файлом сценария http.js: load_module modules/ngx_http_js_module.so; events {} http { - js_include hello_world.js; + js_import http.js; server { listen 8000; location / { - js_content hello; + js_content http.hello; } } } -