Merged
Conversation
5d1ce4b to
db1725d
Compare
This introduces ngx_js_merge_conftime_loc_conf() to handle merging of configuration-time properties. Normally ngx_js_merge_conf() does all the default value initialization for child location configurations. There is a special case for global "http" or "stream" configuration where the parent configuration needs to be initialized (so it can be reused by server configurations if no additional directives were defined in them). But parent configurations are not initialized by ngx_js_merge_conf(). Most of the ngx_js_loc_conf_t values are only used at runtime, so only configuration-time values need to be merged in the parent. The runtime values will be provided from the appropriate ngx_js_loc_conf_t during request processing. Previously, configuration-time merging was done inline. Extracting it into a dedicated function simplifies adding new configuration-time properties.
Added "js_load_http_native_module" and "js_load_stream_native_module"
main nginx.conf level directives. The directives load a dynamic
library. For security reason it is only allowed in the main context.
Later, JS code may import modules loaded with these directives
with standard import syntax.
example.conf:
...
js_load_http_native_module /path/to/lib.so;
js_load_http_native_module /path/to/lib2.so as lib2;
http {
js_import main.js;
...
main.js:
import * as lib from 'lib.so';
import * as lib2 from 'lib2';
...
See quickjs.h for the complete QuickJS API reference and
nginx/t/js_native_module.t for a working example.
This closes nginx#968 feature request on Github.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.