ggzeng
1/11/2020 - 12:38 PM

kong plugin handler

kong插件中handler.lua模板

kong v1.4.x

https://docs.konghq.com/1.4.x/plugin-development/custom-logic/

-- handler.lua
local BasePlugin = require "kong.plugins.base_plugin"

local kong = kong

local CustomHandler = BasePlugin:extend()

CustomHandler.VERSION  = "1.0.0"
CustomHandler.PRIORITY = 10

function CustomHandler:new()
  CustomHandler.super.new(self, "my-custom-plugin")
end

function CustomHandler:access(config)
  CustomHandler.super.access(self)

  kong.log.inspect(config.environment) -- "development"
  kong.log.inspect(config.server.host) -- "http://localhost"
  kong.log.inspect(config.server.port) -- 80
end

return CustomHandler