diff options
author | Dmitry Volyntsev <xeioex@nginx.com> | 2024-06-14 20:54:28 -0700 |
---|---|---|
committer | Dmitry Volyntsev <xeioexception@gmail.com> | 2024-09-17 18:05:57 -0700 |
commit | 201b127679e27fe63eff5c1b4356ec4ed9ec4611 (patch) | |
tree | 2477939f07f646ee6137a7d30ccc8e807206da61 /nginx/t/js_fetch_https.t | |
parent | 9b6744129ce4c18e74b5e41cd1da66f2cbadcf36 (diff) | |
download | njs-201b127679e27fe63eff5c1b4356ec4ed9ec4611.tar.gz njs-201b127679e27fe63eff5c1b4356ec4ed9ec4611.zip |
Modules: introduced QuickJS engine.
"js_engine" directive is introduced which sets JavaScript engine.
When the module is built with QuickJS library "js_engine qjs;" sets
QuickJS engine for the current block. By default njs engine is used.
For example,
nginx.conf:
location /a {
js_engine qjs;
# will be handled by QuickJS
js_content main.handler;
}
location /b {
# will be handled by njs
js_content main.handler;
}
QuickJS engine implements drop-in replacement for nginx/njs objects
with the following exceptions:
* nginx module API to be added later: ngx.fetch(), ngx.shared.dict.
* Built-in modules to be added later: fs, crypto, WebCrypto, xml.
* NJS specific API: njs.dump(), njs.on(), console.dump().
* js_preload_object directive.
Diffstat (limited to 'nginx/t/js_fetch_https.t')
-rw-r--r-- | nginx/t/js_fetch_https.t | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/nginx/t/js_fetch_https.t b/nginx/t/js_fetch_https.t index 9d4ebb0a..9a44a339 100644 --- a/nginx/t/js_fetch_https.t +++ b/nginx/t/js_fetch_https.t @@ -48,6 +48,10 @@ http { js_content test.njs; } + location /engine { + js_content test.engine; + } + location /https { js_content test.https; } @@ -102,6 +106,10 @@ $t->write_file('test.js', <<EOF); r.return(200, njs.version); } + function engine(r) { + r.return(200, njs.engine); + } + function https(r) { var url = `https://\${r.args.domain}:$p1/loc`; var opt = {}; @@ -116,7 +124,7 @@ $t->write_file('test.js', <<EOF); .catch(e => r.return(501, e.message)) } - export default {njs: test_njs, https}; + export default {njs: test_njs, https, engine}; EOF my $d = $t->testdir(); @@ -186,7 +194,11 @@ foreach my $name ('default.example.com', '1.example.com') { . $t->read_file('intermediate.crt')); } -$t->try_run('no njs.fetch')->plan(7); +$t->try_run('no njs.fetch'); + +plan(skip_all => 'not yet') if http_get('/engine') =~ /QuickJS$/m; + +$t->plan(7); $t->run_daemon(\&dns_daemon, port(8981), $t); $t->waitforfile($t->testdir . '/' . port(8981)); |