Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
refactor(handler) no need to to inherit from BasePlugin anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
bungle committed Jun 6, 2019
1 parent a5bc975 commit 56de598
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions kong/plugins/proxy-cache/handler.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
local BasePlugin = require "kong.plugins.base_plugin"
local cache_key = require "kong.plugins.proxy-cache.cache_key"
local utils = require "kong.tools.utils"

Expand Down Expand Up @@ -249,16 +248,11 @@ local function send_response(res)
end


local ProxyCacheHandler = BasePlugin:extend()


ProxyCacheHandler.PRIORITY = 100
ProxyCacheHandler.VERSION = "1.2.1"

local ProxyCacheHandler = {
VERSION = "1.2.1",
PRIORITY = 100,
}

function ProxyCacheHandler:new()
ProxyCacheHandler.super.new(self, "proxy-cache")
end

function ProxyCacheHandler:init_worker()
-- catch notifications from other nodes that we purged a cache entry
Expand Down Expand Up @@ -302,9 +296,8 @@ function ProxyCacheHandler:init_worker()
end)
end

function ProxyCacheHandler:access(conf)
ProxyCacheHandler.super.access(self)

function ProxyCacheHandler:access(conf)
local cc = req_cc()

-- if we know this request isnt cacheable, bail out
Expand Down Expand Up @@ -400,8 +393,6 @@ end


function ProxyCacheHandler:header_filter(conf)
ProxyCacheHandler.super.header_filter(self)

local ctx = ngx.ctx.proxy_cache
-- dont look at our headers if
-- a). the request wasnt cachable or
Expand All @@ -428,8 +419,6 @@ end


function ProxyCacheHandler:body_filter(conf)
ProxyCacheHandler.super.body_filter(self)

local ctx = ngx.ctx.proxy_cache
if not ctx then
return
Expand Down Expand Up @@ -470,4 +459,5 @@ function ProxyCacheHandler:body_filter(conf)
end
end


return ProxyCacheHandler

0 comments on commit 56de598

Please sign in to comment.