mirror of
https://github.com/fluencelabs/jsonpath
synced 2025-07-30 23:02:03 +00:00
openresty 테스트
This commit is contained in:
25
lua/docker_example/default.conf
Normal file
25
lua/docker_example/default.conf
Normal 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
15
lua/docker_example/run.sh
Executable 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"
|
Reference in New Issue
Block a user