diff --git a/.gitignore b/.gitignore index 3c2bcc850f93..444eeac0ec05 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,4 @@ luac.out logs t/servroot go +\.* diff --git a/README.md b/README.md index a982c0f9fadd..0aaa45dcb408 100644 --- a/README.md +++ b/README.md @@ -1 +1,21 @@ -# apimeta \ No newline at end of file +# Summary + +# Design Doc + +### How to load the plugin? + +![](doc/flow-load-plugin.png) + +### Plugin + +![](doc/flow-plugin-internal.png) + + +# Development + +### Source Install + +> Dependent library + +* Setups the [resty-r3#install](https://github.com/iresty/lua-resty-r3#install) library. + diff --git a/conf/config.yaml b/conf/config.yaml index 5f45d127b8cd..c8ca617598c1 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -2,3 +2,6 @@ etcd: host: "http://127.0.0.1:2379" prefix: "/v2/keys" timeout: 60 + +plugins: + - example_plugin diff --git a/doc/apimeta-plugin-design.graffle b/doc/apimeta-plugin-design.graffle new file mode 100644 index 000000000000..280a830e28e0 Binary files /dev/null and b/doc/apimeta-plugin-design.graffle differ diff --git a/doc/flow-load-plugin.png b/doc/flow-load-plugin.png new file mode 100644 index 000000000000..070d233313e5 Binary files /dev/null and b/doc/flow-load-plugin.png differ diff --git a/doc/flow-plugin-internal.png b/doc/flow-plugin-internal.png new file mode 100644 index 000000000000..b84fd602ef72 Binary files /dev/null and b/doc/flow-plugin-internal.png differ diff --git a/lua/apimeta/comm/config.lua b/lua/apimeta/comm/config.lua index 3cc895aff6ef..dd7fde7f914a 100644 --- a/lua/apimeta/comm/config.lua +++ b/lua/apimeta/comm/config.lua @@ -15,7 +15,7 @@ local function read_file(path) return nil end - local content = file:read("*a") -- *a or *all reads the whole file + local content = file:read("*a") -- `*a` reads the whole file file:close() return content end diff --git a/t/yaml-config.t b/t/yaml-config.t index f6e9ecc8b3c7..4dccb5f62568 100644 --- a/t/yaml-config.t +++ b/t/yaml-config.t @@ -15,8 +15,10 @@ __DATA__ content_by_lua_block { local encode_json = require "cjson.safe" .encode local config = require("apimeta.comm.config").read() + ngx.say("etcd host: ", config.etcd.host) ngx.say("etcd prefix: ", config.etcd.prefix) + ngx.say("plugins: ", encode_json(config.plugins)) } } --- request @@ -24,3 +26,4 @@ GET /t --- response_body etcd host: http://127.0.0.1:2379 etcd prefix: /v2/keys +plugins: ["example_plugin"]