apache / apisix-go-plugin-runner

Go Plugin Runner for APISIX
https://apisix.apache.org/
Apache License 2.0
173 stars 68 forks source link

request help: How do i access APISIX variables #105

Closed VetchM closed 2 years ago

VetchM commented 2 years ago

Issue description

I want to access APISIX variables(https://apisix.apache.org/zh/docs/apisix/apisix-variable/) like route_name, service_name in my own plugin, how to achieve this?

Environment

soulbird commented 2 years ago

In RequestFilter, you can use the Var method to get variables: https://github.com/apache/apisix-go-plugin-runner/blob/master/pkg/http/http.go#L61

VetchM commented 2 years ago

Thanks, accessing variable will make a RPC to APISIX, right?

soulbird commented 2 years ago

Yes. In addition, pay attention that the Var method is currently only available in RequestFilter, and not yet supported in ResponseFilter.

soulbird commented 2 years ago

Looks like it's solved, reopen if needed.