我正在嘗試構建一個 Traefik 插件并基于https://github.com/traefik/plugindemo#local-mode在本地模式下對其進行測試現在這個插件什么都不做,只返回“Hello”。這是我的文件結構:在traefik/plugins-local/src/github.com/Hongbo-Miao/traefik-plugin-disable-graphql-introspection文件夾中,我有:.traefik.ymlentryPoints: graphql-server-entrypoint: address: :9000api: insecure: true dashboard: trueproviders: file: filename: dynamic_conf.yamllog: level: DEBUGexperimental: localPlugins: traefik-plugin-disable-graphql-introspection: modulename: github.com/Hongbo-Miao/traefik-plugin-disable-graphql-introspectiongo.modmodule github.com/Hongbo-Miao/traefik-plugin-disable-graphql-introspectiongo 1.17主程序package mainimport ( "context" "net/http")type Config struct{}func CreateConfig() *Config { return &Config{}}type DisableGraphQLIntrospection struct { next http.Handler name string}func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error) { return &DisableGraphQLIntrospection{ next: next, name: name, }, nil}func (a *DisableGraphQLIntrospection) ServeHTTP(rw http.ResponseWriter, req *http.Request) { rw.Write([]byte("hello"))}在根文件夾中,我有traefik.yamlentryPoints: graphql-server-entrypoint: address: :9000api: insecure: true dashboard: trueproviders: file: filename: dynamic_conf.yamllog: level: DEBUGexperimental: localPlugins: traefik-plugin-disable-graphql-introspection: modulename: github.com/Hongbo-Miao/traefik-plugin-disable-graphql-introspection
1 回答

繁星點點滴滴
TA貢獻1803條經驗 獲得超3個贊
得到了 Tom Moulard 的答復,謝謝!https://github.com/traefik/plugindemo/issues/15#issuecomment-1123741949
你的錯誤是八重木找不到包
New
的功能traefik_plugin_disable_graphql_introspection
。因此,您可以判斷 Yaegi 找到了您的插件并加載了它,但找不到包。package main
要解決此問題,您需要將插件代碼中的行更改為package traefik_plugin_disable_graphql_introspection
.
在main.go文件中更改為后package main
,它現在可以工作了!package traefik_plugin_disable_graphql_introspection
- 1 回答
- 0 關注
- 127 瀏覽
添加回答
舉報
0/150
提交
取消