tzssangglass commented on a change in pull request #6370:
URL: https://github.com/apache/apisix/pull/6370#discussion_r812844502



##########
File path: docs/zh/latest/plugin-develop.md
##########
@@ -37,6 +38,51 @@ title: 插件开发
 - [编写测试用例](#编写测试用例)
   - [附上 test-nginx 执行流程](#附上-test-nginx-执行流程)
 
+此文档是关于 lua 语言的插件开发,其他语言请看:[external plugin](./external-plugin.md)。
+
+## 插件放置路径
+
+Apache APISIX 提供了两种方式来添加新的功能。
+
+1. 修改 Apache APISIX 的源代码并重新发布 (不推荐)。
+2. 配置 `extra_lua_path` 和 `extra_lua_cpath` 在 `conf/config.yaml` 以加载你自己的代码文件。 
你应该给自己的代码文件起一个不包含在原来库中的名字,而不是使用相同名称的代码文件,但是如果有需要,你可以使用这种方式覆盖内置的代码文件。
+
+比如,你可以创建一个目录目录结构,像下面这样:
+
+```
+├── example
+│   └── apisix
+│       ├── plugins
+│       │   └── 3rd-party.lua
+│       └── stream
+│           └── plugins
+│               └── 3rd-party.lua
+```
+
+接着,在 `conf/config.yaml` 文件中添加如下的配置:
+
+```yaml
+apisix:
+    ...
+    extra_lua_path: "/path/to/example/?.lua"
+```
+
+现在使用 `require "apisix.plugins.3rd-party"` 会加载你自己的插件, 比如 `require 
"apisix.plugins.jwt-auth"`会加载 `jwt-auth` 插件.
+
+可能你会想覆盖一个文件中的函数,你可以在 `conf/config.yaml` 文件中配置 `lua_module_hook` 来使你的 hook 生效。
+
+你的配置可以像下面这样:
+
+```yaml
+apisix:
+    ...
+    extra_lua_path: "/path/to/example/?.lua"
+    lua_module_hook: "my_hook"
+```
+
+ 当 APISIX 启动的时候,`example/my_hook.lua` 就会被加载,这时你可以使用这个钩子在 APISIX 中来全局替换掉一个方法。

Review comment:
       ```suggestion
   当 APISIX 启动的时候,`example/my_hook.lua` 就会被加载,这时你可以使用这个钩子在 APISIX 中来全局替换掉一个方法。
   ```




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to