Kong / go-pdk

Write Kong plugins in Go! 🦍
https://pkg.go.dev/github.com/Kong/go-pdk
Apache License 2.0
144 stars 48 forks source link

How can I share a Golang object between different phases quickly? #167

Closed 007slm closed 4 months ago

007slm commented 6 months ago

I am developing a rate limiting plugin in Golang. In the plugin's logic, I need to generate a rate limiting object that is related to the current request URL during the access phase for QPS calculation. Then, in the response phase, I need to access this request-specific rate limiting object for further computation. How should I share this object between the two phases?

Water-Melon commented 6 months ago

I'm not familiar with Go PDK, but I guess you may looking for this: https://pkg.go.dev/github.com/Kong/go-pdk@v0.10.0/ctx#Ctx.SetShared

gszr commented 4 months ago

We encourage questions like this in the Discussions forum in the main Kong repo: https://github.com/Kong/kong/discussions.