Mercurial > hg > nginx-site
comparison xml/en/docs/njs/reference.xml @ 2998:050d2e099e16
Added example to r.subrequest in njs Reference.
author | Yaroslav Zhuravlev <yar@nginx.com> |
---|---|
date | Wed, 16 Aug 2023 12:12:22 +0100 |
parents | adecad3d7039 |
children | 7c3182a95cd6 |
comparison
equal
deleted
inserted
replaced
2997:adecad3d7039 | 2998:050d2e099e16 |
---|---|
7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> | 7 <!DOCTYPE article SYSTEM "../../../../dtd/article.dtd"> |
8 | 8 |
9 <article name="Reference" | 9 <article name="Reference" |
10 link="/en/docs/njs/reference.html" | 10 link="/en/docs/njs/reference.html" |
11 lang="en" | 11 lang="en" |
12 rev="112"> | 12 rev="113"> |
13 | 13 |
14 <section id="summary"> | 14 <section id="summary"> |
15 | 15 |
16 <para> | 16 <para> |
17 <link doc="index.xml">njs</link> provides objects, methods and properties | 17 <link doc="index.xml">njs</link> provides objects, methods and properties |
593 if a <literal>callback</literal> is not provided, | 593 if a <literal>callback</literal> is not provided, |
594 the <literal>Promise</literal> object | 594 the <literal>Promise</literal> object |
595 that resolves to the <link id="http">subrequest response object</link> | 595 that resolves to the <link id="http">subrequest response object</link> |
596 is returned. | 596 is returned. |
597 </para> | 597 </para> |
598 | |
599 <para> | |
600 For example, to view all response headers in the subrequest: | |
601 <example> | |
602 async function handler(r) [ | |
603 let reply = await r.subrequest('/path'); | |
604 | |
605 for (var h in reply.headersOut) { | |
606 r.log(`${h}: ${reply.headersOut[h]}`); | |
607 } | |
608 | |
609 r.return(200); | |
610 } | |
611 </example> | |
612 </para> | |
613 | |
598 </tag-desc> | 614 </tag-desc> |
599 | 615 |
600 <tag-name id="r_uri"><literal>r.uri</literal></tag-name> | 616 <tag-name id="r_uri"><literal>r.uri</literal></tag-name> |
601 <tag-desc> | 617 <tag-desc> |
602 current <link doc="../http/ngx_http_core_module.xml" id="var_uri">URI</link> | 618 current <link doc="../http/ngx_http_core_module.xml" id="var_uri">URI</link> |