File tree Expand file tree Collapse file tree 1 file changed +14
-9
lines changed
Expand file tree Collapse file tree 1 file changed +14
-9
lines changed Original file line number Diff line number Diff line change @@ -313,12 +313,13 @@ Example
313313
314314``` Lua
315315 -- Tarantool, stored procedure
316- function foo (req )
317- return {
318- 200 , -- set status HTTP 200
319- { [" X-Tarantool" ] = " FROM_TNT" } -- set headers
316+ function foo (req , ... )
317+ local status = 200
318+ local headers = {
319+ [" X-Tarantool" ] = " FROM_TNT" ,
320320 }
321-
321+ local body = ' It works!'
322+ return status , headers , body
322323 end
323324```
324325
@@ -331,6 +332,7 @@ Example
331332 }
332333
333334 location /tnt_proxy {
335+ internal;
334336 tnt_method tnt_proxy;
335337 tnt_buffer_size 100k;
336338 tnt_pass_http_request on parse_args;
@@ -339,8 +341,6 @@ Example
339341
340342 location /api {
341343
342- lua_need_request_body on;
343-
344344 rewrite_by_lua '
345345
346346 local cjson = require("cjson")
@@ -351,11 +351,16 @@ Example
351351 PUT = ngx.HTTP_PUT,
352352 -- ...
353353 }
354-
354+ -- hide `{"params": [...]}` from a user
355+ ngx.req.read_body()
356+ local body = ngx.req.get_body_data()
357+ if body then
358+ body = "{\\"params\\": [" .. body .. "]}"
359+ end
355360 local res = ngx.location.capture("/tnt_proxy", {
356361 args = ngx.var.args,
357362 method = map[ngx.var.request_method],
358- body = ngx. body
363+ body = body
359364 })
360365
361366 if res.status == ngx.HTTP_OK then
You can’t perform that action at this time.
0 commit comments