Hello,
I'm glad to announce a new release of NGINX JavaScript module (njs).
This release extends http module.
Notable new features:
- raw headers API:
With the following request headers:
: Host: localhost
: Foo: bar
: foo: bar2
All 'foo' headers can be collected with the syntax:
: r.rawHeadersIn.filter(v=>v[0].toLowerCase() == 'foo').map(v=>v[1]);
the output will be:
: ['bar', 'bar2']
- TypeScript API definition:
: foo.ts:
: /// <reference path="ngx_http_js_module.d.ts" />
: function content_handler(r: NginxHTTPRequest)
: {
: r.headersOut['content-type'] = 'text/plain';
: r.return(200, "Hello from TypeScript");
: }
:
: tsc foo.ts --outFile foo.js
foo.js can be used directly with njs.
You can learn more about njs:
- Overview and introduction: http://nginx.org/en/docs/njs/
- 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.4.1 19 May 2020
*) Feature: added support for multi-value headers in r.headersIn.
*) Feature: introduced raw headers API.
*) Feature: added TypeScript API description.
Core:
*) Bugfix: fixed Array.prototype.slice() for sparse arrays._______________________________________________
nginx-announce mailing list
nginx-announce@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-announce