-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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 #253 from Mashape/feature/plugins/default-api-key-…
…name [feature] default key_names to "apikey"
- Loading branch information
Showing
7 changed files
with
85 additions
and
36 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,22 @@ | ||
local utils = require "kong.tools.utils" | ||
|
||
local function default_key_names(t) | ||
if not t.key_names then | ||
return {"apikey"} | ||
end | ||
end | ||
|
||
local function validate_key_names(t) | ||
if type(t) == "table" and not utils.is_array(t) then | ||
local printable_mt = require "kong.tools.printable" | ||
setmetatable(t, printable_mt) | ||
return false, "key_names must be an array. '"..t.."' is a table. Lua tables must have integer indexes starting at 1." | ||
end | ||
|
||
return true | ||
end | ||
|
||
return { | ||
key_names = { required = true, type = "table" }, | ||
key_names = { required = true, type = "table", default = default_key_names, func = validate_key_names }, | ||
hide_credentials = { type = "boolean", default = false } | ||
} |
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 |
---|---|---|
@@ -1,14 +1,14 @@ | ||
return { | ||
add = { require = "false", type = "table", schema = { | ||
form = { required = false, type = "table" }, | ||
headers = { required = false, type = "table" }, | ||
querystring = { required = false, type = "table" } | ||
add = { type = "table", schema = { | ||
form = { type = "table" }, | ||
headers = { type = "table" }, | ||
querystring = { type = "table" } | ||
} | ||
}, | ||
remove = { require = "false", type = "table", schema = { | ||
form = { required = false, type = "table" }, | ||
headers = { required = false, type = "table" }, | ||
querystring = { required = false, type = "table" } | ||
remove = { type = "table", schema = { | ||
form = { type = "table" }, | ||
headers = { type = "table" }, | ||
querystring = { type = "table" } | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
return { | ||
host = { required = true, type = "string" }, | ||
port = { required = true, type = "number" }, | ||
timeout = { required = false, default = 10000, type = "number" }, | ||
keepalive = { required = false, default = 60000, type = "number" } | ||
timeout = { default = 10000, type = "number" }, | ||
keepalive = { default = 60000, type = "number" } | ||
} |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
return { | ||
host = { required = true, type = "string" }, | ||
port = { required = true, type = "number" }, | ||
timeout = { required = false, default = 10000, type = "number" } | ||
timeout = { default = 10000, type = "number" } | ||
} |
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