Browse Source

Update examples

master
Dominic Guana 6 months ago
parent
commit
64b6711578
No account linked to committer's email address
3 changed files with 17 additions and 8 deletions
  1. 13
    4
      README.md
  2. 2
    2
      examples/simple_rest_client.py
  3. 2
    2
      examples/simple_rest_client.sh

+ 13
- 4
README.md View File

@@ -354,7 +354,7 @@ Here is an example with `ngx_lua`:
# Nginx, configuration
upstream tnt_upstream {
127.0.0.1:9999;
server 127.0.0.1:9999;
keepalive 10000;
}
@@ -367,7 +367,7 @@ Here is an example with `ngx_lua`:
}
location /api {
default_type application/json;
rewrite_by_lua '
local cjson = require("cjson")
@@ -402,8 +402,17 @@ Here is an example with `ngx_lua`:
ngx.header[k] = v
end
table.remove(result, 1)
ngx.say(cjson.encode(result))
local body = result[3]
if type(body) == "string" then
ngx.header["content_type"] = "text/plain"
ngx.print(body)
elseif type(body) == "table" then
local body = cjson.encode(body)
ngx.say(body)
else
ngx.status = 502
ngx.say("Unexpected response from Tarantool")
end
else
ngx.status = 502
ngx.say("Tarantool does not work")

+ 2
- 2
examples/simple_rest_client.py View File

@@ -9,8 +9,8 @@ import urllib2
#
# 1. Tarantool conf {{{
# box.cfg {listen = 3113}
# tester = box.schema.space.create('tester', {if_not_exist=true})
# index = tester:create_index('pk', {parts{1, 'str'}})
# tester = box.schema.space.create('tester', {if_not_exists=true})
# index = tester:create_index('pk', {parts={1, 'str'}})
# print ('SPACE_ID = ', tester.id)
# print ('INDEX_ID = ', index.id)
# }}}

+ 2
- 2
examples/simple_rest_client.sh View File

@@ -5,8 +5,8 @@
#
# 1. Tarantool conf {{{
# box.cfg {listen = 3113}
# tester = box.schema.space.create('tester', {if_not_exist=true})
# index = tester:create_index('pk', {parts{1, 'str'}})
# tester = box.schema.space.create('tester', {if_not_exists=true})
# index = tester:create_index('pk', {parts={1, 'str'}})
# print ('SPACE_ID = ', tester.id)
# print ('INDEX_ID = ', index.id)
# }}}

Loading…
Cancel
Save