TykTechnologies / custom-plugin-examples

Custom plugin examples for the Tyk Gateway - if you ever needed to extend the functionality!
https://tyk.io
36 stars 5 forks source link

Update examples for latest version of tyk #10

Open armujahid opened 2 years ago

armujahid commented 2 years ago

Current examples are using older versions of tyk. I think we should update examples to support latest version I was able to compile few basic examples for 4.0.4 version using these steps:

rm -rf go.mod go.sum vendor/
go mod init tyk-plugin
go mod edit -replace github.com/jensneuse/graphql-go-tools=github.com/TykTechnologies/graphql-go-tools@v1.6.2-0.20220426094453-0cc35471c1ca
go get github.com/TykTechnologies/tyk@af3430ae6e1ca689365bf67416c590d3201b7929
<Write and finalize code>
go mod tidy
go mod vendor
docker container run -v $(pwd):/plugin-source --rm tykio/tyk-plugin-compiler:v4.0.4 plugin.so

Signature of ctx.SetSession is changed in latest version that's why go-auth-multiple_hook_example isn't compiling.

Related: https://community.tyk.io/t/go-auth-plugin-example-with-latest-tyk-version-v4-0-4/5635

armujahid commented 2 years ago

gRPC golang auth examples like https://github.com/TykTechnologies/custom-plugins/tree/master/plugins/grpc_go-auth-pre_headerinject_authhook is also not compiling. I am getting this error while trying to run this example using

go mod init tyk-plugin
go mod tidy
 github.com/TykTechnologies/tyk-protobuf/bindings/go: module github.com/TykTechnologies/tyk-protobuf@latest found (v0.0.0-20220714214409-d0cb35aefc54), but does not contain package github.com/TykTechnologies/tyk-protobuf/bindings/go
armujahid commented 2 years ago

I have created this example https://github.com/armujahid/tyk-grpc-go-mongo-accesstoken/ that can be included in this repo. This example is containerized and can be forked to create/deploy grpc plugin on k8s