Closed DanielTimLee closed 7 years ago
The behavior you're seeing is correct. In the init worker phase, nonrequest context is available to load a specific instance of the plugin, and thus no specific configuration can be passed to the handler. The init_worker handler should be used for generic maintenance work and timer initialization logic, but not individual plugins entities. But do also note that you can manually load individual configuration from the data store via the dao
. I believe the bot-detection plugin did this in 0.11.0 (though the logic was simplified in the latest release).
For any further questions on plugin development, please consider using the mailing list or Gitter, as GitHub issues should be reserved for actual bugs with Kong core. Thank you!
Summary
https://getkong.org/docs/0.11.x/plugin-development/custom-logic/#handler-lua-specifications
As I see here, Specification of
handler.lua
hasconfig
object frominit_worker
. But the Problem is, when I try to access config object from theinit_worker
it keeps returning me anil
value.Steps To Reproduce
Kong-Vagrant
Dev env. (with Custom Plugin) from here (https://github.com/Kong/kong-vagrant)schema.lua
Handler.lua
function withinit_worker
.function plugin:init_worker(plugin_conf) plugin.super.access(self) ngx.log(ngx.ERR, plugin_conf) end
<KONG_PREFIX>/logs/error.log
)Nil
Vagrant Default.
Kong-Vagrant ubuntu/trusty64