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

Add BasePlugin deprecation notice and porting tips to plugin development guide #3400

Merged
merged 2 commits into from
Nov 24, 2021
Merged
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
31 changes: 29 additions & 2 deletions app/gateway/2.7.x/plugin-development/custom-logic.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ that a Plugin doesn't need to provide functions for all phases.

```lua
local CustomHandler = {
VERSION = "1.0.0"
PRIORITY = 10
VERSION = "1.0.0",
PRIORITY = 10,
}

function CustomHandler:init_worker()
Expand Down Expand Up @@ -178,6 +178,33 @@ function CustomHandler.access(self, config)
end
```

### Migrating from `BasePlugin` module

The `BasePlugin` module is deprecated and will be removed in a future version
of {{site.ce_product_name}}. If you have an old plugin that uses it, replace
the initial part:

```lua
-- DEPRECATED --
local BasePlugin = require "kong.plugins.base_plugin"

local CustomHandler = BasePlugin:extend()

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

with the current equivalent:
```lua
local CustomHandler = {
VERSION = "1.0.0",
PRIORITY = 10,
}
```

You don't need to add a `:new()` method or call any of the `CustomHandler.super.XXX:(self)`
methods.

The Plugin's logic doesn't need to be all defined inside the `handler.lua` file.
It can be be split into several Lua files (also called *modules*).
The `handler.lua` module can use `require` to include other modules in your plugin.
Expand Down