Skip to content
This repository has been archived by the owner on Dec 11, 2020. It is now read-only.

demo #30

Open
JamesJoe-C opened this issue Sep 11, 2018 · 0 comments
Open

demo #30

JamesJoe-C opened this issue Sep 11, 2018 · 0 comments

Comments

@JamesJoe-C
Copy link

require("route");

local router = require 'router'
local r = router.new()

r:match(route)

local method = ngx.var.request_method;
local post_data = "";

if(method == "POST") then
ngx.req.read_body();
local post_data = ngx.req.get_post_args();
end

local ok, errmsg = r:execute(
method,
ngx.var.request_uri,
ngx.req.get_uri_args(), -- all these parameters
post_data, -- will be merged in order
{other_arg = 1}
) -- into a single "params" table

if ok then
ngx.status = 200
else
ngx.exec("@client")
-- ngx.status = 404
-- ngx.print("Not found!")
-- ngx.log(ngx.ERROR, errmsg)
end

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant