local kong_meta = require "kong.meta"
local json = require "cjson"
json.encode_empty_table_as_object(false)

local PathDeny = {PRIORITY = 1102, VERSION = kong_meta.version}

function PathDeny:access(conf)
    local deny_paths = conf.deny_paths

    local target_path = kong.request.get_path()
    -- deny_paths
    if deny_paths then
        for _, path in ipairs(deny_paths) do
            if ngx.re.find(target_path, path) then
                kong.response.exit(403, json.encode({
                    code = 49900008,
                    message = "The service is under maintenance",
                    details = {}
                }), {["Content-Type"] = "application/json"})
            end
        end
    end
end

return PathDeny
