Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated for kong 3.x #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 4 additions & 9 deletions kong/plugins/path-prefix/handler.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
local plugin = require("kong.plugins.base_plugin"):extend()

function plugin:new()
plugin.super.new(self, "path-prefix")
end
local plugin = {
PRIORITY = 800,
VERSION = "1.0.0"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@HairyMike HairyMike Oct 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good call @clayharris - I suggest revving the version so the plugin can be used in both 2.x and 3.x kong versions.

}

local function escape_hyphen(conf)
local path_prefix = conf.path_prefix
Expand All @@ -24,8 +23,6 @@ local function add_header(conf, path)
end

function plugin:access(plugin_conf)
plugin.super.access(self)

local service_path = ngx.ctx.service.path or ""
local full_path = kong.request.get_path()
local replace_match = escape_hyphen(plugin_conf)
Expand All @@ -45,6 +42,4 @@ function plugin:access(plugin_conf)
kong.service.request.set_path(new_path)
end

plugin.PRIORITY = 800

return plugin