Kong[nginx]-20 插件schema.lua初探
2019-08-27 本文已影响0人
国服最坑开发
0x00 目的
本文想系统的调查一下
Kong
插件支持的参数输入UI
格式,
顺便调查一下是否能实现自己的复杂参数的输入要求.
0x01 先来一张效果图:
效果图0x02 代码实现
再来看一下, 是如何定制这些控制项:
local typedefs = require "kong.db.schema.typedefs"
return {
name = "param_demo",
fields = {
{
config = {
type = "record",
fields = {
{
runTimes = {
type = "number",
default = 0,
between = {
0,
100
}
}
},
{
environment = {
type = "string",
required = true,
one_of = {
"production",
"development"
},
default = "development"
}
},
{
prodMode = {
type = "boolean",
required = true,
default = false
}
},
{
httpActions = {
type = "array",
elements = {
type = "string",
one_of = {
"GET",
"POST"
}
}
}
},
{
appSettings = {
type = "record",
fields = {
{
appKey = {
type = "string",
}
},
{
iOS = {
type = "string"
}
},
{
Android = {
type = "string"
}
},
}
}
},
},
},
},
},
}
本来想调查一下是否能够在array
下面嵌套一层record
,
代码是能正常运行, 但是可能UI
过于复杂, 没有UI
提示,暂时作罢.
TODO
调查注释部分如何编写