Welcome! Log In Create A New Profile

Advanced

[njs] Types: fixed signature of subrequest() with detached: true.

Dmitry Volyntsev
November 02, 2020 07:44AM
details: https://hg.nginx.org/njs/rev/7ae9a0502fa1
branches:
changeset: 1556:7ae9a0502fa1
user: Jakub Jirutka <jakub@jirutka.cz>
date: Sat Oct 31 22:38:22 2020 +0100
description:
Types: fixed signature of subrequest() with detached: true.

Order of method overloading declaration matters.

diffstat:

test/ts/test.ts | 10 +++++++---
ts/ngx_http_js_module.d.ts | 4 ++--
2 files changed, 9 insertions(+), 5 deletions(-)

diffs (44 lines):

diff -r fa3ffb3a159e -r 7ae9a0502fa1 test/ts/test.ts
--- a/test/ts/test.ts Thu Oct 29 12:51:21 2020 +0000
+++ b/test/ts/test.ts Sat Oct 31 22:38:22 2020 +0100
@@ -5,6 +5,7 @@ import crypto from 'crypto';
function http_module(r: NginxHTTPRequest) {
var bs: NjsByteString;
var s: string;
+ var vod: void;

// builtin string vs NjsByteString

@@ -57,9 +58,12 @@ function http_module(r: NginxHTTPRequest

// r.subrequest
r.subrequest('/p/sub1').then(reply => r.return(reply.status));
- r.subrequest('/p/sub2', reply => r.return(reply.status));
- r.subrequest('/p/sub3', {detached:true});
- r.subrequest('/p/sub4', 'a=1&b=2').then(reply => r.return(reply.status,
+ r.subrequest('/p/sub2', {method:'POST'}).then(reply => r.return(reply.status));
+ vod = r.subrequest('/p/sub3', reply => r.return(reply.status));
+ vod = r.subrequest('/p/sub4', {method:'POST'}, reply => r.return(reply.status));
+ vod = r.subrequest('/p/sub5', {detached:true});
+ // Warning: vod = r.subrequest('/p/sub9', {detached:true}, reply => r.return(reply.status));
+ r.subrequest('/p/sub6', 'a=1&b=2').then(reply => r.return(reply.status,
JSON.stringify(JSON.parse(reply.responseBody ?? ''))));

}
diff -r fa3ffb3a159e -r 7ae9a0502fa1 ts/ngx_http_js_module.d.ts
--- a/ts/ngx_http_js_module.d.ts Thu Oct 29 12:51:21 2020 +0000
+++ b/ts/ngx_http_js_module.d.ts Sat Oct 31 22:38:22 2020 +0100
@@ -346,11 +346,11 @@ interface NginxHTTPRequest {
* @param options Subrequest options.
* @param callback Completion callback.
*/
+ subrequest(uri: NjsStringLike, options: NginxSubrequestOptions & { detached: true }): void;
subrequest(uri: NjsStringLike, options?: NginxSubrequestOptions | string): Promise<NginxHTTPRequest>;
- subrequest(uri: NjsStringLike, options: NginxSubrequestOptions | string,
+ subrequest(uri: NjsStringLike, options: NginxSubrequestOptions & { detached?: false } | string,
callback:(reply:NginxHTTPRequest) => void): void;
subrequest(uri: NjsStringLike, callback:(reply:NginxHTTPRequest) => void): void;
- subrequest(uri: NjsStringLike, options: NginxSubrequestOptions & { detached: true }): void;
/**
* Current URI in request, normalized.
*/
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[njs] Types: fixed signature of subrequest() with detached: true.

Dmitry Volyntsev 149 November 02, 2020 07:44AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 70
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready