[njs] Added ngx.conf_prefix.

Dmitry Volyntsev xeioex at nginx.com
Wed Aug 31 23:53:16 UTC 2022


details:   https://hg.nginx.org/njs/rev/26b8f0c2ef94
branches:  
changeset: 1943:26b8f0c2ef94
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Wed Aug 31 16:52:16 2022 -0700
description:
Added ngx.conf_prefix.

diffstat:

 nginx/ngx_js.c |  21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diffs (45 lines):

diff -r dfbd55660d40 -r 26b8f0c2ef94 nginx/ngx_js.c
--- a/nginx/ngx_js.c	Wed Aug 31 16:52:10 2022 -0700
+++ b/nginx/ngx_js.c	Wed Aug 31 16:52:16 2022 -0700
@@ -12,6 +12,10 @@
 #include "ngx_js_fetch.h"
 
 
+njs_int_t ngx_js_ext_conf_prefix(njs_vm_t *vm, njs_object_prop_t *prop,
+    njs_value_t *value, njs_value_t *setval, njs_value_t *retval);
+
+
 extern njs_module_t  njs_webcrypto_module;
 
 
@@ -19,6 +23,14 @@ static njs_external_t  ngx_js_ext_core[]
 
     {
         .flags = NJS_EXTERN_PROPERTY,
+        .name.string = njs_str("conf_prefix"),
+        .u.property = {
+            .handler = ngx_js_ext_conf_prefix,
+        }
+    },
+
+    {
+        .flags = NJS_EXTERN_PROPERTY,
         .name.string = njs_str("ERR"),
         .u.property = {
             .handler = ngx_js_ext_constant,
@@ -305,6 +317,15 @@ ngx_js_ext_flags(njs_vm_t *vm, njs_objec
 
 
 njs_int_t
+ngx_js_ext_conf_prefix(njs_vm_t *vm, njs_object_prop_t *prop,
+    njs_value_t *value, njs_value_t *setval, njs_value_t *retval)
+{
+    return njs_vm_value_string_set(vm, retval, ngx_cycle->conf_prefix.data,
+                                   ngx_cycle->conf_prefix.len);
+}
+
+
+njs_int_t
 ngx_js_ext_log(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs,
     njs_index_t level)
 {



More information about the nginx-devel mailing list