forked from Kong/kong
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Kong#209 from Mashape/refactor/patterns
[refactor] drop pcre regexes for lua patterns
- Loading branch information
Showing
14 changed files
with
96 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
local reg = require "rex_pcre" | ||
|
||
_G.ngx = { | ||
time = function() return os.time() end, -- cassandra.lua | ||
re = { | ||
match = reg.match | ||
}, | ||
-- Builds a querystring from a table, separated by `&` | ||
-- @param tab The key/value parameters | ||
-- @param key The parent key if the value is multi-dimensional (optional) | ||
-- @return a string representing the built querystring | ||
encode_args = function(tab, key) | ||
local query = {} | ||
local keys = {} | ||
|
||
for k in pairs(tab) do | ||
keys[#keys+1] = k | ||
end | ||
|
||
table.sort(keys) | ||
|
||
for _, name in ipairs(keys) do | ||
local value = tab[name] | ||
if key then | ||
name = string.format("%s[%s]", tostring(key), tostring(name)) | ||
end | ||
if type(value) == "table" then | ||
query[#query+1] = build_query(value, name) | ||
else | ||
value = tostring(value) | ||
if value ~= "" then | ||
query[#query+1] = string.format("%s=%s", name, value) | ||
else | ||
query[#query+1] = name | ||
end | ||
end | ||
end | ||
|
||
return table.concat(query, "&") | ||
end | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.