Skip to content

Importing libraries/modules in custom plugins? #11484

Closed Answered by 0xdeadbeer
0xdeadbeer asked this question in Q&A
Discussion options

You must be logged in to vote

I solved it by installing the package into the tree directory of Apisix's installation - make sure the deps folder exists.

# check if amqp-client is installed 
luarocks list --tree=/home/kevinj/src/apisix/deps | grep amqp-client
# no result - not installed yet 

# we install it with: 
luarocks --tree=/home/kevinj/src/apisix/deps install amqp-client

# check again 
luarocks list --tree=/home/kevinj/src/apisix/deps | grep amqp-client
# output: amqp-client

And corrected the import statement - according to the documentation of the module:

...
local http            = require("resty.http")
local url             = require("net.url")
local amqp            = require("amqp")

local tostring = tostring

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by 0xdeadbeer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant