mikyll commented on issue #12389:
URL: https://github.com/apache/apisix/issues/12389#issuecomment-3249251025
To implement this feature, the only two ways that come up to my mind are the
following:
1. parse both `yaml_config` and `extra_yaml_config`, searching for
`apisix.extra_lua_path` (and `apisix.extra_lua_cpath`), save the content to a
variable, and insert it at the beginning of the related Nginx directive.
Example:
```perl
my $extra_lua_path = "";
my $extra_lua_cpath = "";
# Do stuff (and eventually, if the extra path was found, append ";" to
these)
my $lua_deps_path = $block->lua_deps_path // <<_EOC_;
lua_package_path "$extra_lua_path$apisix_home/?.lua;...";
lua_package_cpath "$extra_lua_cpath$apisix_home/?.so;...";
_EOC_
```
2. Use specific block definitions: `extra_lua_path`, `extra_lua_cpath`.
Example:
```perl
my $extra_lua_path = "";
my $extra_lua_cpath = "";
if (defined($block->extra_lua_path)) {
$extra_lua_path = $block->extra_lua_path . ";";
}
if (defined($block->extra_lua_cpath)) {
$extra_lua_cpath = $block->extra_lua_cpath . ";";
}
my $lua_deps_path = $block->lua_deps_path // <<_EOC_;
lua_package_path "$extra_lua_path$apisix_home/?.lua;...";
lua_package_cpath "$extra_lua_cpath$apisix_home/?.so;...";
_EOC_
```
Personally I think the second one is more clean/reliable, since for the
first we would need to manually parse the YAML (or install a dependency) 👀
What do you think? @Baoyuantop
--
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]