2019-08-23 22:09:09 +09:00
|
|
|
lua_package_path '/etc/jsonpath/?.lua;;';
|
|
|
|
|
2019-08-25 15:43:04 +09:00
|
|
|
access_log /var/log/nginx_access.log;
|
2019-08-23 22:09:09 +09:00
|
|
|
error_log /var/log/nginx_error.log info;
|
|
|
|
|
|
|
|
server {
|
|
|
|
listen 80;
|
|
|
|
server_name localhost;
|
|
|
|
|
2019-08-25 15:43:04 +09:00
|
|
|
location /0 {
|
2019-08-23 22:09:09 +09:00
|
|
|
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)
|
|
|
|
';
|
|
|
|
}
|
|
|
|
|
2019-08-25 15:43:04 +09:00
|
|
|
location /1 {
|
|
|
|
default_type text/html;
|
|
|
|
|
|
|
|
content_by_lua_file /etc/jsonpath/testa.lua;
|
|
|
|
}
|
|
|
|
|
2019-08-23 22:09:09 +09:00
|
|
|
location /example {
|
|
|
|
root /etc/jsonpath/example;
|
|
|
|
}
|
|
|
|
}
|