#
# https://github.com/openresty/lua-nginx-module
#

server {
    listen       80;
    server_name  localhost;

    location / {
        root   /usr/local/openresty/nginx/html;
        index  index.html index.htm;
    }

    error_page  500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/local/openresty/nginx/html;
    }

    location /about {
        default_type 'text/plain';
        content_by_lua_block {
            ngx.say('hello, world!')
        }
    }

    location /webhook {
        default_type 'application/json';
        content_by_lua_block {
            local http = require "resty.http"
            local cjson = require "cjson"
            ngx.req.read_body()
            local body = ngx.req.get_body_data()
            local obj = cjson.decode(body)
            # TODO
        }
    }
}
