diff --git a/components/protocol/http/pprof/init.go b/components/protocol/http/pprof/init.go index ef99362..1fbbaef 100644 --- a/components/protocol/http/pprof/init.go +++ b/components/protocol/http/pprof/init.go @@ -1,8 +1,6 @@ package pprof import ( - "net/http" - "github.com/pipeproxy/pipe/components/common/register" ) @@ -11,9 +9,5 @@ const ( ) func init() { - register.Register(name, NewPprofWithConfig) -} - -func NewPprofWithConfig() http.Handler { - return NewPprof() + register.Register(name, NewPprof) } diff --git a/components/protocol/http/pprof/pprof.go b/components/protocol/http/pprof/pprof.go index b063018..4d8ed68 100644 --- a/components/protocol/http/pprof/pprof.go +++ b/components/protocol/http/pprof/pprof.go @@ -9,7 +9,7 @@ import ( type Pprof struct { } -func NewPprof() Pprof { +func NewPprof() http.Handler { return Pprof{} } diff --git a/components/protocol/http/quit/init.go b/components/protocol/http/quit/init.go index 396b9f9..73cd862 100644 --- a/components/protocol/http/quit/init.go +++ b/components/protocol/http/quit/init.go @@ -2,7 +2,6 @@ package quit import ( "github.com/pipeproxy/pipe/components/common/register" - "github.com/pipeproxy/pipe/components/protocol/http" ) const ( @@ -10,9 +9,5 @@ const ( ) func init() { - register.Register(name, NewPprofWithConfig) -} - -func NewPprofWithConfig() http.Handler { - return NewQuit() + register.Register(name, NewQuit) } diff --git a/components/protocol/http/quit/quit.go b/components/protocol/http/quit/quit.go index 8d56a48..0f259e3 100644 --- a/components/protocol/http/quit/quit.go +++ b/components/protocol/http/quit/quit.go @@ -7,14 +7,14 @@ import ( "github.com/pipeproxy/pipe/internal/logger" ) -func NewQuit() *ConfigQuit { - return &ConfigQuit{} +type Quit struct { } -type ConfigQuit struct { +func NewQuit() http.Handler { + return &Quit{} } -func (c *ConfigQuit) ServeHTTP(rw http.ResponseWriter, r *http.Request) { +func (c *Quit) ServeHTTP(rw http.ResponseWriter, r *http.Request) { svc, ok := pipe.GetPipeWithContext(r.Context()) if !ok { http.Error(rw, http.StatusText(http.StatusServiceUnavailable), http.StatusServiceUnavailable)