Valentin V. Bartenev
October 30, 2018 07:58PM
On Wednesday, 31 October 2018 01:47:49 MSK alweiss wrote:
> My problem is that services can be one, two … ten etc … so not easy to place
> in the callback of the previous subrequest ...
>

Actually it's not a problem. Here's an example:

function authorize(r) {
var n = 0;
var svcs = ['one', 'two', 'three'];

var callNextService = function() {

function done(reply) {
if (reply.status == 200) {
r.return(200);
return;
}

callNextService();
}


if (n == svcs.length) {
r.return(403);
return;
}

r.subrequest("/" + svcs[n++], '', done);
}

callNextService();
}

wbr, Valentin V. Bartenev



_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Variable scope in javascript module

alweiss October 26, 2018 02:16AM

Re: Variable scope in javascript module

Dmitry Volyntsev October 26, 2018 05:04AM

Re: Variable scope in javascript module

alweiss October 30, 2018 12:07PM

Re: Variable scope in javascript module

alweiss October 30, 2018 12:58PM

Re: Variable scope in javascript module

Dmitry Volyntsev October 30, 2018 01:10PM

Re: Variable scope in javascript module

Valentin V. Bartenev October 30, 2018 01:12PM

Re: Variable scope in javascript module

alweiss October 30, 2018 05:55PM

Re: Variable scope in javascript module

Valentin V. Bartenev October 30, 2018 06:28PM

Re: Variable scope in javascript module

Maxim Konovalov October 30, 2018 06:32PM

Re: Variable scope in javascript module

alweiss October 30, 2018 07:22PM

Re: Variable scope in javascript module

alweiss October 30, 2018 06:47PM

Re: Variable scope in javascript module

Valentin V. Bartenev October 30, 2018 07:58PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 242
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready