Hello, I'm glad to announce a new release of NGINX JavaScript module (njs).
This release focuses on extending the modules functionality. Notable new features: - ngx.fetch() method implements a generic HTTP client which does not depend on subrequests: : example.js: : function fetch(r) { : ngx.fetch('http://nginx.org/') : .then(reply => reply.text()) : .then(body => r.return(200, body)) : .catch(e => r.return(501, e.message)); : } - js_header_filter directive. The directive allows changing arbitrary header fields of a response header. : nginx.conf: : js_import foo.js; : : location / { : js_header_filter foo.filter; : proxy_passhttp://127.0.0.1:8081/; : } : : foo.js: : function filter(r) { : var cookies = r.headersOut['Set-Cookie']; : var len = r.args.len ? Number(r.args.len) : 0; : r.headersOut['Set-Cookie'] = cookies.filter(v=>v.length > len); : } : : export default {filter}; You can learn more about njs: - Overview and introduction:http://nginx.org/en/docs/njs/ - Presentation:https://youtu.be/Jc_L6UffFOs - Using node modules with njs: http://nginx.org/en/docs/njs/node_modules.html - Writing njs code using TypeScript definition files: http://nginx.org/en/docs/njs/typescript.html Feel free to try it and give us feedback on: - Github:https://github.com/nginx/njs/issues - Mailing list:http://mailman.nginx.org/mailman/listinfo/nginx-devel Changes with njs 0.5.1 16 Feb 2021 nginx modules: *) Feature: introduced ngx.fetch() method implementing Fetch API. The following init options are supported: body, headers, buffer_size (nginx specific), max_response_body_size (nginx specific), method. The following properties and methods of Response object are implemented: arrayBuffer(), bodyUsed, json(), headers, ok, redirect, status, statusText, text(), type, url. The following properties and methods of Header object are implemented: get(), getAll(), has(). Notable limitations: only the http:// scheme is supported, redirects are not handled. In collaboration with 洪志道 (Hong Zhi Dao). *) Feature: added the "js_header_filter" directive. *) Bugfix: fixed processing buffered data in body filter in stream module. Core: *) Bugfix: fixed safe mode bypass in Function constructor. *) Bugfix: fixed Date.prototype.toISOString() with invalid date values.
_______________________________________________ nginx mailing list nginx@nginx.org http://mailman.nginx.org/mailman/listinfo/nginx