lint by golangci-lint (#3080)

This commit is contained in:
fatedier
2022-08-29 01:02:53 +08:00
committed by GitHub
parent f4e4fbea62
commit 9d077b02cf
122 changed files with 947 additions and 1331 deletions

View File

@@ -11,14 +11,14 @@ import (
"github.com/fatedier/frp/test/e2e/mock/server/httpserver"
)
type PluginHandler func(req *plugin.Request) *plugin.Response
type Handler func(req *plugin.Request) *plugin.Response
type NewPluginRequest func() *plugin.Request
func NewHTTPPluginServer(port int, newFunc NewPluginRequest, handler PluginHandler, tlsConfig *tls.Config) *httpserver.Server {
func NewHTTPPluginServer(port int, newFunc NewPluginRequest, handler Handler, tlsConfig *tls.Config) *httpserver.Server {
return httpserver.New(
httpserver.WithBindPort(port),
httpserver.WithTlsConfig(tlsConfig),
httpserver.WithTLSConfig(tlsConfig),
httpserver.WithHandler(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
r := newFunc()
buf, err := io.ReadAll(req.Body)
@@ -35,7 +35,7 @@ func NewHTTPPluginServer(port int, newFunc NewPluginRequest, handler PluginHandl
resp := handler(r)
buf, _ = json.Marshal(resp)
log.Trace("plugin response: %s", string(buf))
w.Write(buf)
_, _ = w.Write(buf)
})),
)
}