我正在尝试构建一个 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 关注
- 141 浏览
添加回答
举报
0/150
提交
取消