This documentation explains how to develop this project.
make setup
installation dependenciesmake install
installation runner to systemmake dev
to start it/path/to/apisix-python-plugin-runner/apisix/plugin
the .py
files in this directory autoload
/path/to/apisix-python-plugin-runner/apisix/plugin/stop.py /path/to/apisix-python-plugin-runner/apisix/plugin/rewrite.py
from apisix.runner.plugin.base import Base from apisix.runner.http.request import Request from apisix.runner.http.response import Response class Test(Base): def __init__(self): super(Test, self).__init__(self.__class__.__name__) def filter(self, request: Request, response: Response): """ The plugin executes the main function :param request: request parameters and information :param response: response parameters and information :return: """ # Get plugin configuration information through `self.config` # print(self.config) # Setting the request object will continue to forward the request # Rewrite request headers request.headers["X-Resp-A6-Runner"] = "Python" # Rewrite request args request.args["a6_runner"] = "Python" # Rewrite request path request.path = "/a6/python/runner" # Setting the response object will terminate the request and respond to the data # Set response headers response.headers["X-Resp-A6-Runner"] = "Python" # Set response body response.body = "Hello, Python Runner of APISIX" # Set response status code response.status_code = 201
Base
classfilter
functionfilter
function parameters can only contain Request
and Response
classes as parametersself.config
can get plug-in configuration informationRun make test
.
1 byte of type + 3 bytes of length + data