我正在尝试构建一个 Traefik 插件并基于https://github.com/traefik/plugindemo#local-mode在本地模式下对其进行测试
现在这个插件什么都不做,只返回“Hello”。
这是我的文件结构:
在traefik/plugins-local/src/github.com/Hongbo-Miao/traefik-plugin-disable-graphql-introspection文件夹中,我有:
.traefik.yml
entryPoints:
graphql-server-entrypoint:
address: :9000
api:
insecure: true
dashboard: true
providers:
file:
filename: dynamic_conf.yaml
log:
level: DEBUG
experimental:
localPlugins:
traefik-plugin-disable-graphql-introspection:
modulename: github.com/Hongbo-Miao/traefik-plugin-disable-graphql-introspection
go.mod
module github.com/Hongbo-Miao/traefik-plugin-disable-graphql-introspection
go 1.17
主程序
package main
import (
"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.yaml
entryPoints:
graphql-server-entrypoint:
address: :9000
api:
insecure: true
dashboard: true
providers:
file:
filename: dynamic_conf.yaml
log:
level: DEBUG
experimental:
localPlugins:
traefik-plugin-disable-graphql-introspection:
modulename: github.com/Hongbo-Miao/traefik-plugin-disable-graphql-introspection
繁星点点滴滴
相关分类