go-pdk
go-pdk copied to clipboard
Impossible to access kong.Router.GetService() from Log phase.
kong 2.8.0 go-pdk v0.7.1
For the moment only it is possible to get kong.Router.GetService()
information from Access phase and not from the Log phase.
Is a possible bug of kong, because the documentation explains that is possible to get this information from the Log phase:
https://docs.konghq.com/gateway/latest/pdk/kong.router/#kongrouterget_service
Any idea if this is a bug?
I'm facing the exactly same problem when trying to access lots of methods from kong.Request
in the log phase. I keep getting the error api disabled in the current context
even though the data should be accessible according to Kong and NGINX docs
Passing by to comment that it is still the case. For instance it fails for kong.Request
on :
-
GetPath
-
GetMethod
-
GetQuery
- ...
For some reason I tried to port a lua version to a Go version and everything that worked on the log phase about the request failed. The Response access seems to work as expected though.
Quick investigations about this error message lead me here : https://github.com/Kong/kong/blob/master/build/openresty/patches/ngx_lua-0.10.26_01-dyn_upstream_keepalive.patch#L1031-L1034 so I guess it's because the lua context is not matching the Go context (or something like this) ?
This is a known limitation; Kong communicates with the plugin server through a Unix domain socket. The socket API we use for that is not available in the context where we run the Go plugin log handler (it is actually in the context of a timer). I will tag this one as an enhancement request for now. Thank you for the discussion over here!
@gszr it would be great to add a disclaimer in the docs for this to let people know of this limitation. Specially because it's not only the .GetService()
that doesn't work
@edjanmichiles-toast Good call - we will work on that.
Hey, I'm facing the same issue here using the latest go-pdk version (0.11.0). Is there any news on this topic? Also, no document update was made as far as I can tell, right?