How to access information in custom plugins using python PDK ?
khangt1k25 opened this issue · 5 comments
I am using Python PDK to write a custom Plugin for the Kong gateway. Everything setup is done and it's working with the py-hello example. But in the access phase, I want to retrieve all the context and information of the service, consumer. How can I do that. Most of the return value is Table type. Take a look to this example.
service = kong.router.get_service()
I want to get the service id for example. How can i do that. Thank you
hi @khangt1k25 if you are uncertain of the return type, use print
to debug
service = kong.router.get_service()
print("service is ", service)
hi @fffonion , As i said before, the return value is table type. I am using kong.log to debug the type. But if just return
table x0193d24adxa
But in python, i want to get information from this table. How can i parse this table to normal format or access property of that using other way? Thank you
@khangt1k25 you can just use python's print
, every thing on stdout will be inside kong's error log
I wont show any line. I am using docker to deploy the Kong. Is there any arg -v to add any command to start plugin?
you may need to set kong's log_level
to debug
if you haven't do so.