-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(api) parent arg was missing in plugin endpoint handlers (Kong#5174)
Customization of Admin API endpoints for DAO objects return a 4th argument `parent` for the handler function, which contains the original implementation of the endpoint. This argument was missing for endpoints declared by plugins. This fix makes it possible for a plugin's endpoint handler in `api.lua` to reuse the original function via `parent` when overriding Admin API functions like we do in some core DAO routes.
- Loading branch information
Showing
5 changed files
with
198 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
spec/fixtures/custom_plugins/kong/plugins/api-override/api.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
local kong = kong | ||
|
||
|
||
return { | ||
["/routes"] = { | ||
schema = kong.db.routes.schema, | ||
GET = function(_, _, _, parent) | ||
kong.response.set_header("Kong-Api-Override", "ok") | ||
return parent() | ||
end, | ||
POST = function(_, _, _, parent) | ||
kong.response.set_header("Kong-Api-Override", "ok") | ||
return parent() | ||
end, | ||
}, | ||
} |
1 change: 1 addition & 0 deletions
1
spec/fixtures/custom_plugins/kong/plugins/api-override/handler.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
return {} |
27 changes: 27 additions & 0 deletions
27
spec/fixtures/custom_plugins/kong/plugins/api-override/schema.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
local typedefs = require "kong.db.schema.typedefs" | ||
|
||
|
||
return { | ||
name = "api-override", | ||
fields = { | ||
{ | ||
protocols = typedefs.protocols { | ||
default = { | ||
"http", | ||
"https", | ||
"tcp", | ||
"tls", | ||
"grpc", | ||
"grpcs" | ||
}, | ||
}, | ||
}, | ||
{ | ||
config = { | ||
type = "record", | ||
fields = { | ||
}, | ||
}, | ||
}, | ||
}, | ||
} |