I can’t make Go plugin to work, it’s load is broken at startup. I followed the docs, but I might have missed something.
e8b6854e2edc4ecab1afc9f445942/my_plugin_v4.1.0_linux_amd64.so"): /opt/tyk-gateway/middleware/bundles/b6de8b6854e2edc4ecab1afc9f445942/apigw_plugin_v4.1.0_linux_amd64.so: cannot open shared object file: No such file or directory mwPath=/opt/tyk-gateway/middleware/bundles/b6de8b6854e2edc4ecab1afc9f445942/apigw_plugin_v4.1.0_linux_amd64.so mwSymbolName=MyPreHook
Plugin init with the ‘git show-ref tags/v4.1.0’ hash
Welcome to Tyk Community and thank you for posting your question here. I used your plugin and manifest and it seems that I can properly run this plugin in my environment using v4.1.0.
Make sure that you set these required configurations in your tyk.conf.
My plugin looks like this:
package main
import (
"net/http"
"log"
)
func MyPreHook(rw http.ResponseWriter, r *http.Request) {
r.Header.Add("X-test-pre", "pre_hook_AAA")
log.Println("THISISPLUGINLOG")
}
func main() {}
As for building the plugin, these are the steps I made for v4.1.0:
Then here’s how I build it in the gateway: /opt/tyk-gateway/tyk bundle build -y --output="build2.zip"
I also made sure that my API definition got this: "custom_middleware_bundle": "build2.zip",
Note: If you are using docker to run TYK in Macbook M1, the error cannot open shared object file: No such file or directory might also appear and you need to set this variable before installing TYK to force docker to use amd64: export DOCKER_DEFAULT_PLATFORM=linux/amd64
I had this exact problem. Interestingly, forcing docker to use amd64 as suggested didn’t work. I had to pull the amd64 image and specify the platform when running the gateway image even though I had inspected the image manifest and confirmed that it amd64 is supported. Pulling another image worked.
This is on Tyk v4.2.2
docker pull --platform=linux/amd64 [tyk-image]
docker run --platform=linux/amd64 [tyk-image]