Extending an existing plugin

Are there any examples for extending an existing plugin? I am looking at extending the request transformer plugin to add the consumer id and consumer username to the JSON body of a request.

My 2 main questions are

  1. Can I create a new plugin like so?

    local RequestTransformerPlugin = require "kong.plugins.request-transformer.handler"
    local MyPluginHandler = RequestTransformerPlugin:extend()

  2. Does the schema for the new plugin have to match the schema of the request transformer plugin? If not then how do you transform the schema before calling the super method?



1 Like