@@ -48,6 +48,7 @@ Tarantool - https://hub.docker.com/r/tarantool/tarantool
4848 * [ tnt_pass_http_request] ( #tnt_pass_http_request )
4949 * [ tnt_pass_http_request_buffer_size] ( #tnt_pass_http_request_buffer_size )
5050 * [ tnt_method] ( #tnt_method )
51+ * [ tnt_set_header] ( #tnt_set_header )
5152 * [ tnt_send_timeout] ( #tnt_send_timeout )
5253 * [ tnt_read_timeout] ( #tnt_read_timeout )
5354 * [ tnt_buffer_size] ( #tnt_buffer_size )
@@ -480,7 +481,7 @@ Example
480481
481482tnt_pass_http_request
482483------------------
483- ** syntax:** * tnt_pass_http_request [ on|off|parse_args|unescape|pass_body|pass_headers_out] *
484+ ** syntax:** * tnt_pass_http_request [ on|off|parse_args|unescape|pass_body|pass_headers_out|parse_urlencoded ] *
484485
485486** default:** * off*
486487
@@ -519,6 +520,7 @@ Examples #1
519520 req .body -- request body, type string
520521 end
521522```
523+
522524Examples #2 (pass_headers_out)
523525``` nginx
524526 location @tnt {
@@ -543,6 +545,24 @@ Examples #2 (pass_headers_out)
543545 end
544546```
545547
548+ Examples #3 (parse_urlencoded)
549+ ``` nginx
550+ location /tnt {
551+ tnt_http_rest_methods post;
552+ tnt_pass_http_request on parse_urlencoded;
553+ tnt_method tarantool_stored_procedure_name;
554+ tnt_pass 127.0.0.1:9999;
555+ }
556+ ```
557+ ``` lua
558+ function tarantool_stored_procedure_name (req , ...)
559+ req .headers -- a lua table
560+ req .query -- a string
561+ req .body -- a lua table with url encoded args
562+ return true
563+ end
564+ ```
565+
546566``` bash
547567 # Call tarantool_stored_procedure_name()
548568 $> wget NGINX_HOST/tarantool_stored_procedure_name/some/mega/path? q=1
@@ -551,7 +571,7 @@ Examples #2 (pass_headers_out)
551571[ Back to content] ( #content )
552572
553573tnt_pass_http_request_buffer_size
554- ------------------------
574+ ---------------------------------
555575** syntax:** * tnt_pass_http_request_buffer_size SIZE*
556576
557577** default:** * 4k, 8k*
@@ -563,14 +583,14 @@ Specify the size of the buffer used for `tnt_pass_http_request`.
563583[ Back to content] ( #content )
564584
565585tnt_method
566- -----------
586+ ----------
567587** syntax:** * tnt_method STR*
568588
569589** default:** * no*
570590
571591** context:** * location, location if*
572592
573- Specify the Tarantool call method.
593+ Specify the Tarantool call method. It can take a nginx's variable.
574594
575595Examples
576596``` nginx
@@ -584,26 +604,90 @@ Examples
584604 tnt_pass_http_request on;
585605 tnt_pass 127.0.0.1:9999;
586606 }
607+
608+ location ~ /api/([-_a-zA-Z0-9/]+)/ {
609+ # Also tnt_pass_http_request can mix with JSON communication [[
610+ tnt_http_rest_methods get;
611+ tnt_method $1;
612+ #]]
613+
614+ # [on|of]
615+ tnt_pass_http_request on;
616+ tnt_pass 127.0.0.1:9999;
617+ }
618+
587619```
588620``` lua
589621 function tarantool_stored_procedure_name (req , ...)
590622 req .headers -- lua table
591623 req .query -- string
592624 return { ' OK' }
593625 end
626+
627+ function call (req , ...)
628+ req .headers -- lua table
629+ req .query -- string
630+ return req , ...
631+ end
594632```
595633``` bash
596634 # OK Call tarantool_stored_procedure_name()
597635 $> wget NGINX_HOST/tarantool_stored_procedure_name/some/mega/path? q=1
598636
599637 # Error Call tarantool_stored_procedure_XXX()
600638 $> wget NGINX_HOST/tarantool_stored_procedure_XXX/some/mega/path? q=1
639+
640+ # OK Call api_function
641+ $> wget NGINX_HOST/api/call/path? q=1
642+
643+ ```
644+
645+ [ Back to content] ( #content )
646+
647+ tnt_set_header
648+ --------------
649+ ** syntax:** * tnt_set_header STR STR*
650+
651+ ** default:** * no*
652+
653+ ** context:** * location, location if*
654+
655+ Allows redefining or appending fields to the request header passed to the
656+ tarantool proxied server. The value can contain text, variables, and their combinations.
657+
658+ Examples
659+ ``` nginx
660+ location tnt {
661+ # Also tnt_pass_http_request can mix with JSON communication [[
662+ tnt_http_rest_methods get;
663+ tnt_method tarantool_stored_procedure_name;
664+ #]]
665+
666+ tnt_set_header X-Host $host;
667+ tnt_set_header X-GEO-COUNTRY $geoip_country_code;
668+
669+ # [on|of]
670+ tnt_pass_http_request on;
671+ tnt_pass 127.0.0.1:9999;
672+ }
673+
674+ ```
675+ ``` lua
676+ function tarantool_stored_procedure_name (req , ...)
677+ req .headers [' X-Host' ] -- a hostname
678+ req .headers [' X-GEO-COUNTRY' ] -- a geo country
679+ return { ' OK' }
680+ end
681+ ```
682+ ``` bash
683+ # OK Call tarantool_stored_procedure_name()
684+ $> wget NGINX_HOST/tarantool_stored_procedure_name/some/mega/path? q=1
601685```
602686
603687[ Back to content] ( #content )
604688
605689tnt_send_timeout
606- -------------------
690+ ----------------
607691** syntax:** * tnt_send_timeout TIME*
608692
609693** default:** * 60s*
0 commit comments