From 423b60b33077b90a2dbcbcc053c172ea54e0ddc8 Mon Sep 17 00:00:00 2001 From: seasrain <99347745@qq.com> Date: Sat, 18 Sep 2021 11:24:02 +0800 Subject: [PATCH] fix:http server start panic when use Endpoint (#1492) --- transport/http/server.go | 10 ---------- transport/http/server_test.go | 10 ---------- 2 files changed, 20 deletions(-) diff --git a/transport/http/server.go b/transport/http/server.go index 15dc0b57a..da8a29fe6 100644 --- a/transport/http/server.go +++ b/transport/http/server.go @@ -91,13 +91,6 @@ func ErrorEncoder(en EncodeErrorFunc) ServerOption { } } -// Endpoint with server endpoint. -func Endpoint(endpoint *url.URL) ServerOption { - return func(o *Server) { - o.endpoint = endpoint - } -} - // TLSConfig with TLS config. func TLSConfig(c *tls.Config) ServerOption { return func(o *Server) { @@ -227,9 +220,6 @@ func (s *Server) filter() mux.MiddlewareFunc { // http://127.0.0.1:8000?isSecure=false func (s *Server) Endpoint() (*url.URL, error) { s.once.Do(func() { - if s.endpoint != nil { - return - } lis, err := net.Listen(s.network, s.address) if err != nil { s.err = err diff --git a/transport/http/server_test.go b/transport/http/server_test.go index 69a2ceb00..5be44e8a2 100644 --- a/transport/http/server_test.go +++ b/transport/http/server_test.go @@ -7,7 +7,6 @@ import ( "fmt" "io/ioutil" "net/http" - "net/url" "strings" "testing" "time" @@ -201,15 +200,6 @@ func TestLogger(t *testing.T) { // todo } -func TestEndpoint(t *testing.T) { - u, err := url.Parse("http://hello/world") - assert.NoError(t, err) - o := &Server{} - Endpoint(u)(o) - assert.Equal(t, "hello", o.endpoint.Host) - assert.Equal(t, "http", o.endpoint.Scheme) -} - func TestMiddleware(t *testing.T) { o := &Server{} v := []middleware.Middleware{