为了账号安全,请及时绑定邮箱和手机立即绑定

traefik.go:命令 traefik 错误:无法评估新:未定义:xxx

traefik.go:命令 traefik 错误:无法评估新:未定义:xxx

Go
蝴蝶刀刀 2022-12-13 10:44:41
我正在尝试构建一个 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


查看完整回答
反对 回复 2022-12-13
  • 1 回答
  • 0 关注
  • 141 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号