openresty 테스트

This commit is contained in:
freestrings
2019-08-23 22:09:09 +09:00
parent b5c5d6b88e
commit 422a23ee57
8 changed files with 124 additions and 54 deletions

View File

@@ -0,0 +1,25 @@
lua_package_path '/etc/jsonpath/?.lua;;';
error_log /var/log/nginx_error.log info;
server {
listen 80;
server_name localhost;
location / {
default_type text/html;
content_by_lua '
local jsonpath = require("jsonpath")
jsonpath.init("/etc/jsonpath/libjsonpath_lib.so")
local data = ngx.location.capture("/example.json")
local template = jsonpath.compile("$..book[?(@.price<30 && @.category==\'fiction\')]")
local result = template(data.body)
ngx.say(result)
';
}
location /example {
root /etc/jsonpath/example;
}
}

15
lua/docker_example/run.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/usr/bin/env bash
# cd lua/docker_example && ./run.sh
set -v
docker run -d --rm --name jsonpath \
-v "${PWD}/../../benchmark/example.json":/etc/jsonpath/example/example.json:ro \
-v "${PWD}/../jsonpath.lua":/etc/jsonpath/jsonpath.lua:ro \
-v "${PWD}/../target/release/deps/libjsonpath_lib.so":/etc/jsonpath/libjsonpath_lib.so:ro \
-v "${PWD}/default.conf":/etc/nginx/conf.d/default.conf \
-p 8080:80 \
openresty/openresty:bionic
docker exec -it jsonpath bash -c "curl localhost"